[New-bugs-announce] [issue22070] Use the _functools module to speed up functools.total_ordering

Nick Coghlan report at bugs.python.org
Fri Jul 25 18:46:19 CEST 2014

New submission from Nick Coghlan:

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?

messages: 223967
nosy: ncoghlan, rhettinger
priority: normal
severity: normal
status: open
title: Use the _functools module to speed up functools.total_ordering
type: performance
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list