[New-bugs-announce] [issue34925] 25% speed-up to common case bisect()
Raymond Hettinger
report at bugs.python.org
Sun Oct 7 23:33:04 EDT 2018
New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:
The common case for bisect calls is to have two positional arguments and no keyword arguments. For this case, PyArg_ParseTupleAndKeywords() is unnecessarily expensive.
Timings
-------
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 152 nsec per loop
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 152 nsec per loop
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 152 nsec per loop
------- patched --------
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 112 nsec per loop
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 113 nsec per loop
$ pytime -r 11 -s 'from bisect import bisect' -s 'arr=list(range(5))' 'bisect(arr, 2)'
2000000 loops, best of 11: 113 nsec per loop
----------
components: Extension Modules
messages: 327317
nosy: rhettinger
priority: normal
severity: normal
status: open
title: 25% speed-up to common case bisect()
type: performance
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34925>
_______________________________________
More information about the New-bugs-announce
mailing list