Methods¶
-
class
StorageMethod
(**kwargs)[source]¶ Bases:
pimpmyclass.methods.NamedMethod
A property that can store and retrieve information in the instance to which is attached.
Methods and descriptors are class attributes and therefore any attempt to naively modify one of their attributes for a single instance of the parent class will propagate to all instances. This property overcomes this problem by storing information at the instance level.
The information is stored in uniquely a specified namespace defined by the derived class. Inside that storage, another namespace is specified using the property name.
Derived class should use the dynamically created _store_get and _store_set to retrieve and store information.
..note: Derived classes must override the following variables:
- _storage_ns : str
- Defines a unique namespace under which the information of the derived class is stored.
- _storage_ns_init : callable
- Called upon initialization of the storage to initialize the specific storage of the namespace.
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.
-
class
StatsMethod
(**kwargs)[source]¶ Bases:
pimpmyclass.methods.StorageMethod
A property that keep stats on get and set calls.
Stats can be retrieved with the stat methods and the following keys: - call - failed_call
The following statistics are provided in a namedtuple:
- last : float
- most recent duration (seconds).
- count : int
- number of operations.
- mean : float
- average duration per operation (seconds).
- std : float
- standard deviation of the duration (seconds).
- min : float
- shortest duration (seconds).
- max : float
- longest duration (seconds).
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.
-
class
LogMethod
(**kwargs)[source]¶ Bases:
pimpmyclass.methods.NamedMethod
Other Parameters: log_values ((default=True))
-
class
TransformMethod
(**kwargs)[source]¶ Bases:
pimpmyclass.methods.InstanceConfigurableMethod
Other Parameters: params ((default=None))