[issue21185] heapq fails to print in sorted order for certain inputs
Josh Rosenberg
report at bugs.python.org
Wed Apr 9 23:33:42 CEST 2014
Josh Rosenberg added the comment:
It's not really relevant what a heapified list looks like (and there is no reason to guarantee a particular appearance, since it's an implementation detail that could change). It's supposed to function as a heap with the heap functions, that's all. The docs do give a guarantee that a sorted list is already "heapified", but that's a one way guarantee: All sorted lists are heaps, but not all heaps are sorted lists.
The docs also mention the big-O behavior of heapify; it's linear time, O(n), while good general purpose sorting algorithms are O(n log n). A linear algorithm cannot sort a general list.
----------
nosy: +josh.rosenberg
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21185>
_______________________________________
More information about the Python-bugs-list
mailing list