Message215757
With bytearray, you can do:
>>> bytearray(3)
bytearray(b'\x00\x00\x00')
However, with arrays:
>>> array.array('i', 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
Given that int passed as seconf argument is not handled specially in array, I'd like to propose to make it an initial size of a zero-filled array to create. This will make it: a) consitent with bytearray; b) efficient for the scenarios where one needs to pre-create array of given length, pass to some (native) function to fill in, then do rest of processing. For the latter case, assuming that both fill-in and further processing is efficient (e.g. done by native function), the initial array creation becomes a bottleneck. |
|
Date |
User |
Action |
Args |
2014-04-08 13:32:06 | pfalcon | set | recipients:
+ pfalcon |
2014-04-08 13:32:06 | pfalcon | set | messageid: <1396963926.18.0.0845457465299.issue21180@psf.upfronthosting.co.za> |
2014-04-08 13:32:06 | pfalcon | link | issue21180 messages |
2014-04-08 13:32:05 | pfalcon | create | |
|