New submission from Paul Sokolovsky: 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. ---------- components: Library (Lib) messages: 215757 nosy: pfalcon priority: normal severity: normal status: open title: Cannot efficiently create empty array.array of given size, inconsistency with bytearray type: performance versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21180> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com