Strange array.array performance

Scott David Daniels Scott.Daniels at Acm.Org
Fri Feb 20 08:42:19 CET 2009


Maxim Khitrov wrote:
> ... Here's the function that I'll be using from now on. It gives me
> exactly the behavior I need, with an int initializer being treated as
> array size. Still not as efficient as it could be if supported
> natively by array (one malloc instead of two + memmove + extra
> function call), but very good performance nevertheless:
> 
> from array import array as _array
> array_null = dict((tc, '\0' * _array(tc).itemsize) for tc in 'cbBuhHiIlLfd')
How about:
   array_null = dict((tc, _array(tc, (0,)).tostring() for tc in 
'cbBuhHiIlLfd')
...
(some ancient floating points did not use all-0 bytes for 0.0).

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list