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.

Author da
Recipients da
Date 2018-05-21.21:11:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526937064.06.0.682650639539.issue33593@psf.upfronthosting.co.za>
In-reply-to
Content
It'd be really great if we could have support for using the `heapq` module on typed arrays from `array`. For example:


```
import array
import heapq
import random

a = array.array('I', (random.randrange(10) for _ in range(10)))
heapq.heapify(a)
```

Right now this code throws a TypeError:

    TypeError: heap argument must be a list


I suppose I could use `bisect` to insert items one by one but I imagine a single call to heapify() would be more efficient, especially if I'm loading the array from a byte string.

From what I can tell the problem lies in the C implementation, since removing the _heapq imports at the end of the heapq module (in 3.6) makes it work.
History
Date User Action Args
2018-05-21 21:11:04dasetrecipients: + da
2018-05-21 21:11:04dasetmessageid: <1526937064.06.0.682650639539.issue33593@psf.upfronthosting.co.za>
2018-05-21 21:11:04dalinkissue33593 messages
2018-05-21 21:11:03dacreate