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

2013-09-10 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 ___

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

2013-09-10 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 ___

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

2013-09-10 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing lis

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

2013-09-10 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 tra

[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 perf

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

2013-09-08 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file31671/merge.diff ___ Python tracker ___ ___ Python-bugs-list mailing l

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

2013-09-08 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file31681/merge2.diff ___ Python tracker ___ ___ Python-bugs-list mailing li

[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 ___ ___

[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() loo

[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 ___

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

2013-09-07 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[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