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

Wouter Bolsterlee report at bugs.python.org
Sun Sep 8 14:14:44 CEST 2013


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 for the last remaining iterable. Example: merge([], [], [], range(100000). This would involve some more refactoring inside the function though, since the current implementation only stores the .next() function for each iterable.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18962>
_______________________________________


More information about the Python-bugs-list mailing list