Re: Efficient array creation
Robert Bradshaw <[email protected]> Fri, 27 Jun 2008 18:04:08 -0700
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
On Jun 27, 2008, at 2:15 PM, Brad Schick wrote: > Is there an efficient way to create python array instances in pyrex > code? I use python arrays to return data fairly often, but the > resulting C code is fairly involved. For a fixed size array, [item1, item2, ...] is about as efficient as you get. In Cython (and I believe in Pyrex too, though I'm not sure) the append method is translated into the correct C call, and in Cython one can do list comprehension as well, e.g. if you have a C array of ints, then [arr[i] for i from 0 <= i < n] will turn it into a Python list. - Robert