The goal of this PR is to use lazy evaluated and cached attributes on the model class.
By doing so we can avoid to pre-evaluate, for all the models, certain features like _properties or _inherits_from which could be time consuming.
Thanks to the usage of @lazy_class_attribute we do evaluate the property only once per model type and reuse the evaluation result for the following calls.
An other change done by this PR is to use slots in the Model, thanks to this we can reduce the memory footprint of the model instances without negatively impacting the performances.
NOTE: PR #329 objective was only to extend @cached_property to be used in meta classes, the extension has not be used here because we would have had to override __getattribute__ as well causing a performance hit of ~7-9%.
Coverage decreased (-0.2%) to 98.313% when pulling 939c17c2b2beca1744c6ac880916aedebc0627ba on macisamuele:maci-use-lazy-attributes-on-Model into 89774d2af9c3dc81f40f9a73d7bad77207166ea5 on Yelp:master.
The goal of this PR is to use lazy evaluated and cached attributes on the model class. By doing so we can avoid to pre-evaluate, for all the models, certain features like
_properties
or_inherits_from
which could be time consuming.Thanks to the usage of
@lazy_class_attribute
we do evaluate the property only once per model type and reuse the evaluation result for the following calls.An other change done by this PR is to use
slots
in theModel
, thanks to this we can reduce the memory footprint of the model instances without negatively impacting the performances.NOTE: PR #329 objective was only to extend
@cached_property
to be used in meta classes, the extension has not be used here because we would have had to override__getattribute__
as well causing a performance hit of ~7-9%.