Beating TimSort at Merging
earthly.dev
Beating TimSort at Merging
1–10 of 72 posts
Re: Beating TimSort at Merging
#2Re: Beating TimSort at Merging
#3Re: Beating TimSort at Merging
#4Re: Beating TimSort at Merging
#5Re: Beating TimSort at Merging
#6> Timsort overcomes this disadvantage by being written in C rather than Python.
Yeah, Python is SLOW. Thankfully the author dug into C. That was nice to see.
Edit: lol I have no idea why this is being downvoted. Y’all weird.
Re: Beating TimSort at Merging
#7edit: Okay one reason is that heapq.merge is written in python:
https://github.com/python/cpython/blob/6252670732c68420c2a8b...
It might also be since the python version has more options (like arbitrarily many iterables), but I presume it's the fact that the extension is written in C.
Re: Beating TimSort at Merging
#8Re: Beating TimSort at Merging
#9It seems like the built in heapq.merge() should be as fast as the implementation here. I mean if it's really just merging sorted lists, why wouldn't it be as fast as this implementation? edit: Okay one reason is that heapq.merge is written in python: https://github.com/python/cpython/blob/6252670732c68420c2a8b... It might also be since the python version has more options (like arbitrarily many iterables), but I presu…
Re: Beating TimSort at Merging
#10Oops, just for fun the numpy documentation currently states: "The datatype determines which of ‘mergesort’ or ‘timsort’ is actually used, even if ‘mergesort’ is specified. User selection at a finer scale is not currently available." Awesome ...
Also, apparently mergesort may also be done using radix sort for integers "‘mergesort’ and ‘stable’ are mapped to radix sort for integer data types."