Bug in Python?

Terry Reedy tjreedy at udel.edu
Sat Feb 27 06:48:51 EST 2016


On 2/27/2016 4:44 AM, Steven D'Aprano wrote:
> On Sat, 27 Feb 2016 07:55 pm, Terry Reedy wrote:
>
>> In other words, when that doc says *list*, it means a *list*.
>>
>> "To create a heap, use a list initialized to [], or you can transform a
>> populated list into a heap via function heapify()."
> [...]
>> "A heap must be an instance of *list* (and not a subclass thereof).  To
>> create a heap, start with [] or transform an existing list into a heap
>> via function heapify()."
>
> I think that's a sad decision. heapq ought to be able to handle any list
> subclass, not just actual lists. Preferably it ought to handle duck-typed
> lists too, anything with a list-like interface. It is okay if the optimized
> C version only works with actual lists, and falls back to a slower Python
> version for anything else.

Propose that on the tracker, after checking previous issues.

-- 
Terry Jan Reedy



More information about the Python-list mailing list