Roundup Robot added the comment:
New changeset 0e70bf1f32a3 by Raymond Hettinger in branch 'default':
Issue #18962: Optimize the single iterator case for heapq.merge()
http://hg.python.org/cpython/rev/0e70bf1f32a3
--
nosy: +python-dev
___
Python
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
Wouter Bolsterlee added the comment:
Thanks for the quick response.
Btw, do I understand correctly code cleanups are not welcome, even when
touching the code anyway?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
Wouter Bolsterlee added the comment:
(In case you missed it: my latest comment included a cleaned up version of an
earlier patch.)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
Wouter Bolsterlee added the comment:
Thanks Raymond, that is exactly what I had in mind (see my previous comment).
Here's a slightly cleaned up version of the patch (stylistic/PEP8 cleanups),
with some benchmarks included below.
In case the two longest iterators have about the same size, no
Wouter Bolsterlee added the comment:
An additional speedup would be to add a if len(h) == 1 check inside the while
loop, and just yield from the remaining iterator if a single iterable remains.
This would also speed up merges with multiple inputs, as it doesn't do the
whole heapreplace() loop
Raymond Hettinger added the comment:
Try this patch.
--
Added file: http://bugs.python.org/file31671/merge.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
Added file: http://bugs.python.org/file31681/merge2.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
Removed file: http://bugs.python.org/file31671/merge.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
New submission from Wouter Bolsterlee:
The heapq.merge() function merges multiple sorted iterables into a single
sorted output. The function uses a heap queue that is repeatedly looped over
until it has generated all output.
If only a single iterable is passed to heapq.merge(), the heap will
Changes by Benjamin Peterson benja...@python.org:
--
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18962
___
___
Raymond Hettinger added the comment:
At first glance, this looks reasonable. I'll give it a more thorough look
shortly.
--
assignee: - rhettinger
versions: +Python 3.4 -Python 3.3
___
Python tracker rep...@bugs.python.org
12 matches
Mail list logo