Open daveraja opened 2 years ago
Do you know how often the ordering-methods are called? In dataclasses these methods always starts with
if other.__class__ is self.__class__
instead of usingisinstance
, but i have not checked if this gives any performance improvements
__eq__()
(and __hash__()
) are called a lot when adding to sets and factbases. And for sorting and query __lt__()
(and less often __gt__()
) are also called a lot. So anything that we can do to make them faster would help. They probably should be included in the "templated" functions even if that only reduces a few checks.
If someone use the clone-method quite often to just modify one value we could modify the method to just call pytocl for the changed values, don't call init and do all the other required stuff in the clone-method?
Yes, that would be useful. It might also be useful to do the templating thing here as well and generate a custom function signature with keywords only and default to MISSING
.
Some performance tweaks for predicate facts. A few more things are pushed into the templating so that they are calculated when Predicate is sub-classed. Also the fact hash value is calculated and cached at fact creation time and not later in the hash() function.