Message369012
The attached recursive_merge.py should be much less ugly and still somewhat performant.
It should be the same algorithm as that PR, just written recursively rather than iteratively.
I got some text files from http://www.gwicks.net/dictionaries.htm and tried merging them line-by-line:
py -3.9 -m pyperf timeit -s "from heapq import merge; from collections import deque" "deque(merge(open('english.txt'), open('dutch.txt'), open('french.txt'), open('german.txt'), open('italian.txt')), maxlen=0)"
Mean +- std dev: 391 ms +- 9 ms
py -3.9 -m pyperf timeit -s "from recursive_merge import merge; from collections import deque" "deque(merge(open('english.txt'), open('dutch.txt'), open('french.txt'), open('german.txt'), open('italian.txt')), maxlen=0)"
Mean +- std dev: 262 ms +- 9 ms
Perhaps that's a more real-world benchmark. |
|
Date |
User |
Action |
Args |
2020-05-16 05:36:09 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, tim.peters, rhettinger, serhiy.storchaka, bbayles |
2020-05-16 05:36:09 | Dennis Sweeney | set | messageid: <1589607369.26.0.0640500047821.issue38938@roundup.psfhosted.org> |
2020-05-16 05:36:09 | Dennis Sweeney | link | issue38938 messages |
2020-05-16 05:36:09 | Dennis Sweeney | create | |
|