PyMemoize
PyMemoize copied to clipboard
Overload etag/etagger (and other potential pairs, e.g.: key/keyer)
If we restrict the types that are allowed to be used as etags (and/or user-specified keys, see #4), then we could allow either a scalar etag or a function to create said etag to be passed via the same etag
kwarg.
Potential set of types could be:
- strings
- ints
- bools
- None
- tuples of these
Basically, hashable builtin types.
Also, overload the methods on a decorated function to be used as decorators themselves:
@memo
def myfunc(a, b):
pass
@myfunc.etag
def myfunc(a, b):
return str((a, b))
Just need a relatively comprehensive iscallable
to do the detection, since we have already declared that memoized callables may only use hashable arguments.
Would be great if this would also support direct assignment:
myfunc.etag = common_etagger