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

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

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 tho...@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

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

2010-06-14 Thread Hrvoje Niksic
Thomas Jollans tho...@jollans.com writes: On 06/14/2010 01:18 PM, Hrvoje Niksic wrote: Thomas Jollans tho...@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

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 tho...@jollans.com writes: On 06/14/2010 01:18 PM, Hrvoje Niksic wrote: Thomas Jollans tho...@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

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

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

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
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

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

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

2010-06-13 Thread Martin
On Jun 13, 6:15 pm, Thomas Jollans tho...@jollans.com 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

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 robert.k...@gmail.com 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