This document describes the current stable version of Kombu (4.0). For development docs, go here.

Functional-style Utilities - kombu.utils.functional

Functional Utilities.

class kombu.utils.functional.LRUCache(limit=None)[source]

LRU Cache implementation using a doubly linked list to track access.

Parameters:limit (int) – The maximum number of keys to keep in the cache. When a new key is inserted and the limit has been exceeded, the Least Recently Used key will be discarded from the cache.
incr(key, delta=1)[source]
items()[source]
iteritems()
iterkeys()
itervalues()
keys()[source]
popitem(last=True)[source]
update(*args, **kwargs)[source]
values()[source]
kombu.utils.functional.memoize(maxsize=None, keyfun=None, Cache=<class kombu.utils.functional.LRUCache>)[source]

Decorator to cache function return value.

class kombu.utils.functional.lazy(fun, *args, **kwargs)[source]

Holds lazy evaluation.

Evaluated when called or if the evaluate() method is called. The function is re-evaluated on every call.

Overloaded operations that will evaluate the promise:
__str__(), __repr__(), __cmp__().
evaluate()[source]
kombu.utils.functional.maybe_evaluate(value)[source]

Evaluate value only if value is a lazy instance.

kombu.utils.functional.is_list(l, scalars=(<class '_abcoll.Mapping'>, <type 'basestring'>), iters=(<class '_abcoll.Iterable'>, ))[source]

Return true if the object is iterable.

Note

Returns false if object is a mapping or string.

kombu.utils.functional.maybe_list(l, scalars=(<class '_abcoll.Mapping'>, <type 'basestring'>))[source]

Return list of one element if l is a scalar.

kombu.utils.functional.dictfilter(d=None, **kw)[source]

Remove all keys from dict d whose value is None.