[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Roundup Robot
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

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18962 ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Wouter Bolsterlee
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

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-11 Thread Wouter Bolsterlee
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 ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-10 Thread Wouter Bolsterlee
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

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Wouter Bolsterlee
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

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger
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 ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger
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 ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger
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 ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-07 Thread Wouter Bolsterlee
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

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-07 Thread Benjamin Peterson
Changes by Benjamin Peterson benja...@python.org: -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18962 ___ ___

[issue18962] Add special case for single iterator in heapq.merge function

2013-09-07 Thread Raymond Hettinger
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