[New-bugs-announce] [issue4207] Remove backwards compatibility in _heapq for performance
Kristján Valur Jónsson
report at bugs.python.org
Sun Oct 26 12:53:07 CET 2008
New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:
Comparing _heapq with our own legacy C implementation, blue.heapq at
CCP, I noticed that ours was somewhat faster.
I discovered that a lot of effort is being spent to dynamically search
for a __lt__ operator, to provide backwards compatibility. I think we
should consider dropping that after this much time, especially for a
new python version. Running this code:
from timeit import *
s = """
l = [random.random() for i in xrange(10000)]
print "heapify", Timer("heapq.heapify(list(l))", s).timeit(100)
s = s + """
print "pushpop", Timer("heapq.heappushpop(l,random.random())", s).timeit
before. After the patch, we get:
This is "release" code on a snappy windows machine.
components: Extension Modules
keywords: easy, patch, patch
title: Remove backwards compatibility in _heapq for performance
versions: Python 2.6
Added file: http://bugs.python.org/file11889/heapq1.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce