Задать вопрос

Тел: +7 965 3737 888

470

Просмотров

0

Ответов

Automatic Memoization Decorator

<p>This decorator will memoize the results of instance methods, similar to django.util.functional.memoize, but automatically creates a cache attached to the object (and therefore shares the life span of the object) rather than requiring you to provide your own. Note this is intended for instance methods only, though it may work in some cases with functions and class methods with at least one argument.</p>
<p>This is useful for memozing results of model methods for the life of a request. For example:</p>
class MyModel(models.Model):
    #Fields here

    @auto_memoize
    def some_calculation(self):
        #some calculation here
        return result

Вопрос полезен? Да0/Нет0
file_4332.py(715.0б)
None