Skip to content

Instantly share code, notes, and snippets.

View surenkov's full-sized avatar
💨
I may be slow to respond.

Savva Surenkov surenkov

💨
I may be slow to respond.
View GitHub Profile
@surenkov
surenkov / services.py
Last active October 7, 2019 17:07
Some minimal service abstraction
from abc import ABC, abstractmethod
from functools import reduce
from typing import Tuple, TypeVar, Union, Iterable, Mapping
TInstance = TypeVar("TInstance")
class AbstractFactory(Iterable[TInstance], ABC):
pass
@surenkov
surenkov / memoized.py
Created October 7, 2019 16:23
Memoized Method descriptor
from functools import partial
class MemoizedMethod:
def __init__(self, func):
self.func = func
def __get__(self, obj, objtype=None):
if obj is None:
return self.func