[issue44605] functools.total_ordering doesn't work with metaclasses
Raymond Hettinger
report at bugs.python.org
Sun Jul 25 12:37:03 EDT 2021
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
To add support for metaclasses, replacing 'self.__lt__(other)' with 'type(self).__lt__(self, other)' will work.
The performance degradation for the common case is about 25%:
$ py -m timeit -s 'from tmp import a, b' 'a >= b' # op_result = type(self).__lt__(self, other)
1000000 loops, best of 5: 283 nsec per loop
$ py -m timeit -s 'from tmp import a, b' 'a >= b' # op_result = self.__lt__(other)
1000000 loops, best of 5: 227 nsec per loop
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44605>
_______________________________________
More information about the Python-bugs-list
mailing list