Re: efficiently create and fill array.array from C code?

2010-06-14 Thread Thomas Jollans
On 06/14/2010 09:47 PM, Hrvoje Niksic wrote: > Thomas Jollans writes: > >> On 06/14/2010 01:18 PM, Hrvoje Niksic wrote: >>> Thomas Jollans 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 awar

Re: efficiently create and fill array.array from C code?

2010-06-14 Thread Hrvoje Niksic
Thomas Jollans writes: > On 06/14/2010 01:18 PM, Hrvoje Niksic wrote: >> Thomas Jollans 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]) * s

Re: efficiently create and fill array.array from C code?

2010-06-14 Thread Thomas Jollans
On 06/14/2010 01:18 PM, Hrvoje Niksic wrote: > Thomas Jollans 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 preallocat

Re: efficiently create and fill array.array from C code?

2010-06-14 Thread Hrvoje Niksic
Thomas Jollans 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

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread geremy condra
On Sun, Jun 13, 2010 at 1:20 PM, Robert Kern wrote: > On 2010-06-13 14:17 , Stefan Behnel wrote: >> >> Stephen Hansen, 13.06.2010 21:05: >>> >>> On 6/13/10 11:41 AM, Stefan Behnel wrote: Take a look at a) NumPy and b) Cython. You can also use Cython with the array module, but NumPy

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Martin
On Jun 13, 6:15 pm, Thomas Jollans wrote: > Hi, > > I'm writing some buffer-centric number-crunching routines in C for > Python code that uses array.array objects for storing/manipulating data. > I would like to: > > 1. allocate a buffer of a certain size > 2. fill it > 3. return it as an array. >

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Robert Kern
On 2010-06-13 14:17 , Stefan Behnel wrote: Stephen Hansen, 13.06.2010 21:05: On 6/13/10 11:41 AM, Stefan Behnel wrote: Take a look at a) NumPy and b) Cython. You can also use Cython with the array module, but NumPy is a much more common way to deal with "number crunching routines", especially m

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Stefan Behnel
Stephen Hansen, 13.06.2010 21:05: On 6/13/10 11:41 AM, Stefan Behnel wrote: Take a look at a) NumPy and b) Cython. You can also use Cython with the array module, but NumPy is a much more common way to deal with "number crunching routines", especially multi-dimentional arrays. Does Cython suppo

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Stephen Hansen
On 6/13/10 11:41 AM, Stefan Behnel wrote: > Take a look at a) NumPy and b) Cython. You can also use Cython with the > array module, but NumPy is a much more common way to deal with "number > crunching routines", especially multi-dimentional arrays. Does Cython support Py3k yet? The OP seemed to be

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Stefan Behnel
Thomas Jollans, 13.06.2010 19:15: I'm writing some buffer-centric number-crunching routines in C for Python code that uses array.array objects for storing/manipulating data. I would like to: 1. allocate a buffer of a certain size 2. fill it 3. return it as an array. Take a look at a) NumPy and

Re: efficiently create and fill array.array from C code?

2010-06-13 Thread Stephen Hansen
On 6/13/10 10:15 AM, Thomas Jollans wrote: > Hi, > > I'm writing some buffer-centric number-crunching routines in C for > Python code that uses array.array objects for storing/manipulating data. > I would like to: Take this with a grain of salt: I am *not* a C programmer, and my usage of the Pyt

efficiently create and fill array.array from C code?

2010-06-13 Thread Thomas Jollans
Hi, I'm writing some buffer-centric number-crunching routines in C for Python code that uses array.array objects for storing/manipulating data. I would like to: 1. allocate a buffer of a certain size 2. fill it 3. return it as an array. I can't see any obvious way to do this with the array modul