New submission from Raymond Hettinger <raymond.hettin...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue34925>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to