[Python-ideas] A key parameter for heapq.merge

Simon Sapin simon.sapin at kozea.fr
Mon Jan 9 08:17:24 CET 2012

Le 09/01/2012 00:46, Steven D'Aprano a écrit :
> and this is faster still:
> if key is None:
>       for value in heap:
>           do_something_with(value)
> else:
>       for value in heap:
>           do_something_with(key(value))

Yes, this is what I meant by duplicating the loop, though 
do_something_with() is a bit longer:


 > YMMV; I encourage you to benchmark.

I have a working patch with tests. I’ll do a benchmarks next. After that 
is filing an issue?

Simon Sapin

More information about the Python-ideas mailing list