efficiently create and fill array.array from C code?
Hrvoje Niksic
hniksic at xemacs.org
Mon Jun 14 07:18:00 EDT 2010
Thomas Jollans <thomas at jollans.com> writes:
> 1. allocate a buffer of a certain size
> 2. fill it
> 3. return it as an array.
The fastest and more robust approach (I'm aware of) is to use the
array.array('typecode', [0]) * size idiom to efficiently preallocate the
array, and then to get hold of the pointer pointing into array data
using the buffer interface.
Please send a message to capi-sig at python.org, a SIG specializing in the
Python/C API, if you need more help with implementing this.
More information about the Python-list
mailing list