lazy 1.7.dev0 – Lazy Attributes

The lazy module provides a decorator to create lazy attributes.

A lazy attribute is a computed attribute that is evaluated only once, the first time it is used. Subsequent uses return the results of the first call.

The decorator is fully typed. Type checkers can infer the type of a lazy attribute from the return value of the decorated method.

API Documentation

class lazy.lazy(func)

lazy descriptor.

Used as a decorator to create lazy attributes. Lazy attributes are evaluated on first use.

classmethod lazy.invalidate(inst, name)

Invalidate lazy attribute name of instance inst.

This obviously violates the lazy contract. Subclasses of lazy may however have a contract where invalidation is appropriate.

Indices and Tables