[Python-ideas] Specify number of items to allocate for array.array() constructor
Philip Jenvey
pjenvey at underboss.org
Thu Jul 21 02:08:23 CEST 2011
On Jul 20, 2011, at 3:02 PM, Antoine Pitrou wrote:
>
> Hello,
>
>> Is there a reason why there the array.array constructor does not allow
>> to simply specify the number of items that should be allocated? (I do
>> not really care about the contents.)
>> Would this be a worthwhile addition to / modification of the array module?
>
> I think it would be. Rather than an additional constructor parameter,
> perhaps it could be a separate method (like we already have extend(),
> fromfile(), etc.).
+1, Jython's had a custom function for this forever, originally from its old jarray module: jarray.zeros(length, typecode). I think its swapped order of args are due to jarray probably predating the array module.
--
Philip Jenvey
More information about the Python-ideas
mailing list