This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Use the _functools module to speed up functools.total_ordering
Type: performance Stage:
Components: Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alex, ncoghlan, rhettinger
Priority: normal Keywords:

Created on 2014-07-25 16:46 by ncoghlan, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg223967 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-07-25 16:46
Getting functools.total_ordering to handle NotImplemented correctly in issue 10042 came at the cost of slowing it down dramatically, as the simple use of normal operator syntax had to be replaced by explicit method calls. It also introduced the quirk of going through "self.method" lookup rather than "type(self).method" slot lookup (I didn't actually notice that part during the patch review).

It would be nice if we could regain some of that lost speed, and the most readily available approach would seem to be making use of the _functools accelerator module to move the slot dispatch down into C where it can compete with the eval loop based implementation used prior to 3.4.

Raymond, I recall you were doing some speed comparisons between writing out the methods manually and using functools.total_ordering, do you have a handy micro-benchmark readily available?
msg223968 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2014-07-25 16:47
If you're going to fix the semantics of the method lookup to go via the type, can you please do that for the pure python version as well? When the C and Python versions diverge on semantics, it becomes a real pain for alternate implementations which are perfectly happy with the performance of the pure python version ;-)
msg223970 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-07-25 17:01
Fixing the lookup semantics should arguably be a bug report in its own
right, but yes, if the C implementation uses _PyType_LookupSpecial,
then the Python version should definitely be changed to match.
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66268
2014-07-25 17:01:30ncoghlansetmessages: + msg223970
2014-07-25 16:47:58alexsetnosy: + alex
messages: + msg223968
2014-07-25 16:46:19ncoghlancreate