[issue33593] Support heapq on typed arrays?

2018-05-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: As noted by Serhiy, the interaction with the Array type would incur significant overhead. Your fastest approach will be to follow his suggest to first convert to a list and then perform heap manipulations. Marking this as

[issue33593] Support heapq on typed arrays?

2018-05-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Workaround: alist = list(a) heapq.heapify(alist) a[:] = alist And it should be not much slower than using heapq.heapify() directly if it could support general sequences. Using it with array.array would add significant overhead

[issue33593] Support heapq on typed arrays?

2018-05-22 Thread Diego Argueta
Diego Argueta added the comment: However I do see your point about the speed. -- ___ Python tracker ___

[issue33593] Support heapq on typed arrays?

2018-05-22 Thread Diego Argueta
Diego Argueta added the comment: I was referring to the C arrays in the Python standard library: https://docs.python.org/3/library/array.html -- ___ Python tracker

[issue33593] Support heapq on typed arrays?

2018-05-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think we should go down this path. The efficiency of the C implementation depends on it being tightly coupled to lists. This tool is used in the schedulers of various async tools (such as Tornando), used for merge(),

[issue33593] Support heapq on typed arrays?

2018-05-21 Thread Diego Argueta
New submission from Diego Argueta : 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)))