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).


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?


Makes a callable lazy. Could this also be implemented as a decorator? And could a function be both memoized and made 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.


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


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