This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make heapq work with all mutable sequences
Type: enhancement Stage:
Components: Extension Modules Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: bboissin, brett.cannon, rhettinger
Priority: normal Keywords:

Created on 2009-01-14 16:40 by bboissin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg79859 - (view) Author: Benoit Boissinot (bboissin) Date: 2009-01-14 16:40
Generalize heapq to work with all kind of mutable sequences. It should
be investigated PySequence_SetItem is a lot slower than PyList_SET_ITEM
(same for GET_ITEM and GET_SIZE).
msg79865 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-01-14 17:45
This was discussed at the outset and the decision was a conscious one.

Do you have any particular use cases in mind (what other mutable
sequences do you reach for when you need a heap)?  Or is this just a
general discussion on generalization?
msg79866 - (view) Author: Benoit Boissinot (bboissin) Date: 2009-01-14 17:53
I was thinking about array.array. I don't know if it would be faster
than using a list, but it seemed elegant to be able to do a heap on it
anyway.
msg79869 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-01-14 18:14
array.array is terribly slow.  It is optimized for space, not speed.
msg80732 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-01-29 00:14
With no compelling use cases, it's not worth slowing down the module. 
Am sticking with the original design decision.
msg319632 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-06-15 18:05
FYI I had a teacher reach out to me who wanted to use heapq as an example of functions-based API that worked without resorting to OOP but ran into this issue of heapq being limited to lists.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49198
2018-06-15 18:05:26brett.cannonsetnosy: + brett.cannon
messages: + msg319632
2009-01-29 00:14:39rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg80732
2009-01-14 18:14:38rhettingersetmessages: + msg79869
2009-01-14 17:53:01bboissinsetmessages: + msg79866
2009-01-14 17:45:53rhettingersetassignee: rhettinger
messages: + msg79865
nosy: + rhettinger
versions: + Python 3.1, Python 2.7
2009-01-14 16:40:27bboissincreate