Google Groups

django.utils.functional documentation


Daniele Procida Sep 9, 2013 3:47 AM
Posted in group: Django developers
There are caching/laziness-related functions and classes in django.utils.functional, but none seem to be documented (apart from cached_property which has documentation forthcoming).


django.utils.functional.memoize

Caches the output of a function in a dictionary. Could this be implemented as a decorator, and if so, would that be a more elegant way to make use of it?


django.utils.functional.lazy

Makes a callable lazy. Could this also be implemented as a decorator? And could a function be both memoized and made lazy?


django.utils.functional.allow_lazy

A decorator that makes a function respect the laziness of its arguments - if it's called with lazy arguments, it will itself become lazy.


django.utils.functional.LazyObject
django.utils.functional.SimpleLazyObject

Wrappers to make classes lazy. The difference between them is that when the wrapped classes are finally instantiated, the former makes it possible to manipulate the instantiation. The difference between these and django.utils.functional.lazy:

* lazy() can be applied to any callable, not just objects
* lazy() needs to know in advance what type the resulting items will be, whereas these don't


django.utils.functional.Promise
django.utils.functional.curry
django.utils.functional.lazy_property

I can't work out what these are for. Are they things that ought to be documented?


Daniele