Memoize

class systemtools.Memoize(function=None)

Memoize decorator.

Caches function return value.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_systemtools { graph [label=systemtools]; "abjad.tools.systemtools.Memoize.Memoize" [color=black, fontcolor=white, group=1, label=<<B>Memoize</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.dict" [color=1, group=0, label=dict, shape=box]; "builtins.object" [color=1, group=0, label=object, shape=box]; "builtins.object" -> "builtins.dict"; } "builtins.dict" -> "abjad.tools.systemtools.Memoize.Memoize"; }

Bases

  • builtins.dict
  • builtins.object

Attribute summary

clear(() -> None.  Remove all items from D.)
copy(() -> a shallow copy of D)
get((k[,d]) -> D[k] if k in D, ...)
items(...)
keys(...)
pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised
popitem(() -> (k, v), ...) 2-tuple; but raise KeyError if D is empty.
setdefault((k[,d]) -> D.get(k,d), ...)
update(([E, ...) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
values(...)
__call__(\*args) Calls decorator on args.
__contains__ True if D has a key k, else False.
__delitem__ Delete self[key].
__eq__ Return self==value.
__ge__ Return self>=value.
__getitem__ x.__getitem__(y) <==> x[y]
__gt__ Return self>value.
__iter__ Implement iter(self).
__le__ Return self<=value.
__len__ Return len(self).
__lt__ Return self<value.
__missing__(key) Calls function on *key and caches.
__ne__ Return self!=value.
__new__ Create and return a new object.
__repr__ Return repr(self).
__setitem__ Set self[key] to value.

Methods

(dict).clear() → None. Remove all items from D.
(dict).copy() → a shallow copy of D
(dict).get(k[, d]) → D[k] if k in D, else d. d defaults to None.
(dict).items() → a set-like object providing a view on D's items
(dict).keys() → a set-like object providing a view on D's keys
(dict).pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

(dict).popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

(dict).setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
(dict).update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

(dict).values() → an object providing a view on D's values

Special methods

Memoize.__call__(*args)

Calls decorator on args.

Calls function on args and caches if no cached value is found.

Returns cached value.

(dict).__contains__()

True if D has a key k, else False.

(dict).__delitem__()

Delete self[key].

(dict).__eq__()

Return self==value.

(dict).__ge__()

Return self>=value.

(dict).__getitem__()

x.__getitem__(y) <==> x[y]

(dict).__gt__()

Return self>value.

(dict).__iter__()

Implement iter(self).

(dict).__le__()

Return self<=value.

(dict).__len__()

Return len(self).

(dict).__lt__()

Return self<value.

Memoize.__missing__(key)

Calls function on *key and caches.

Returns cached value.

(dict).__ne__()

Return self!=value.

(dict).__new__()

Create and return a new object. See help(type) for accurate signature.

(dict).__repr__()

Return repr(self).

(dict).__setitem__()

Set self[key] to value.