[issue17834] Add Heap (and DynamicHeap) classes to heapq module

2013-04-24 Thread Daniel Wong
New submission from Daniel Wong: heapq already provides a bunch of functions for manipulating lists that preserve (or create) a heap invariant. My change adds two classes for representing heaps. These classes ensure that operations that violate the heap invariant are not possible (through the

[issue17834] Add Heap (and DynamicHeap) classes to heapq module

2013-04-24 Thread Daniel Wong
Daniel Wong added the comment: Hey Serhiy, Are you suggesting that I put my new classes in a new module and rename them? I think it'd be better to keep them in heapq, unless someone intended to add more classes to your proposed queue module, because heap functionality would be spread be

[issue17834] Add Heap (and DynamicHeap) classes to heapq module

2013-04-24 Thread Daniel Wong
Daniel Wong added the comment: Ah, Serhiy is pointing out that there's already a class named PriorityQueue in the queue module. I didn't know that exists. Now that I've had a chance to look at it, queue.PriorityQueue is like my Heap class, but there are some interesting diffe

[issue17794] Priority Queue

2013-04-24 Thread Daniel Wong
Daniel Wong added the comment: from the peanut gallery: This looks right to me; you are seeing that PriorityQueue is trying to compare dicts, because that's how tuple comparison works: it is lexicographic. Since the first element of the two tuples that you are trying to insert have the

[issue17794] Priority Queue

2013-04-26 Thread Daniel Wong
Daniel Wong added the comment: btw, I have a related patch: http://bugs.python.org/issue17834 Chances of it being accepted aren't looking good right now though. -- ___ Python tracker <http://bugs.python.org/is