[issue17834] Add Heap (and DynamicHeap) classes to heapq module
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 public interface). The also allow customization via subclassing. -- components: Library (Lib) files: heap.patch hgrepos: 185 keywords: patch messages: 187723 nosy: allyourcode priority: normal severity: normal status: open title: Add Heap (and DynamicHeap) classes to heapq module type: enhancement Added file: http://bugs.python.org/file30004/heap.patch ___ Python tracker <http://bugs.python.org/issue17834> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17834] Add Heap (and DynamicHeap) classes to heapq module
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 between two modules (heapq and queue). One could argue that these classes could go in the collections module, but I think sticking to heapq is best. -- ___ Python tracker <http://bugs.python.org/issue17834> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17834] Add Heap (and DynamicHeap) classes to heapq module
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 difference; moreover, I'm also proposing DynamicHeap, which is pretty different from PriorityQueue. Perhaps, I should find a way to augment PriorityQueue so that it supports the interesting features of DynamicHeap? -- ___ Python tracker <http://bugs.python.org/issue17834> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17794] Priority Queue
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 same value, comparison of the two tuple reduces to comparing the second elements. Your work around also looks good to me. -- components: +Library (Lib) -Interpreter Core nosy: +allyourcode ___ Python tracker <http://bugs.python.org/issue17794> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17794] Priority Queue
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/issue17794> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com