zzlib.cls module¶
zzlib.cls
¶
zzlib.cls.CachedDelayed
¶
Bases: Delayed[T]
Used to store a function and all its arguments for later calls, with result cache.
zzlib.cls.CachedDelayedTuple
¶
Used to represent each results from a function call tuple result.
zzlib.cls.DecoMeta
¶
Bases: type
A metaclass that automatically decorates all methods with a specified decorator.
If a class defines __deco__ as a function, this metaclass will apply that decorator
to all method functions defined in the class.
The decorator is applied during class creation and affects only methods defined directly in the class, not inherited methods.
Example
zzlib.cls.Def = object.__new__(_DefaultType)
module-attribute
¶
A singleton object representing a default value, distinct from None.
zzlib.cls.Delayed
¶
Bases: Generic[T]
Used to store a function and all its arguments for later calls.
Example
trigger(**kw)
¶
Execute the stored function with stored arguments and additional keyword arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kw |
Additional keyword arguments that will be merged with stored ones. |
{}
|
Returns:
| Type | Description |
|---|---|
T
|
The result of calling the stored function. |
zzlib.cls.FactoryProxy
¶
zzlib.cls.Lazy
¶
Bases: FactoryProxy
A class that delays function execution and caches the result.
Similar to FactoryProxy but caches the result after first execution. Subsequent accesses will return the cached value instead of re-executing the function. The cached value can be reset using reset().
Example
zzlib.cls.LazyLoad
¶
Bases: FactoryProxy
A class that delays function execution until load() is called.
This class allows deferring execution of functions until explicitly loaded. The function result is cached after first load.
Example
zzlib.cls.LazyTuple
¶
A class that lazily executes functions returning tuples. Each tuple element is lazily evaluated separately.
This allows deferring execution of functions that return multiple values, with function being executed when any output is accessed.
Example
zzlib.cls.Patcher
¶
A class that allows upgrading existing objects by adding methods and properties while preserving the original C fingerprint. This enables compatibility in scenarios where the exact type matters.
The upgrade process executes the __upgrade__() method which can initialize new attributes similar
to __init__(). The original object can be converted to the upgraded class type.
Note: Patched objects are not pickle-compatible and must be re-patched after unpickling, including in multiprocessing scenarios.
zzlib.cls.ProxyBase
¶
A proxy class that delegates attribute access to its __subject__ unless explicitly overridden.
Attributes listed in __noproxy__ will not be proxied to __subject__. By default,
functions and properties are not proxied. All attributes must be listed in __noproxy__.
The proxy behaves identically to direct access of the underlying __subject__ for all
non-overridden attributes.