[Pyrex] Question, plus suggestions for improvement?

Giovanni Bajo rasky at develer.com
Tue Aug 1 20:55:13 UTC 2006


Bill Mill wrote:

> 1) I see very few native C operations in the source code, just
> eyeballing it. How could I restructure my code to bring more in?

Use more native types.

> 2) Could I make list access faster? Optionally convert the list into
> an array of (integers, characters, strings, etc) by a user's argument?

If you need to perform many accesses, it's better to convert it to a
standard C array of integers/floats, allocated with malloc() (and freed with
free()). You can index it with any "cdef int" variable, and this will
provide C-like performance. This is especially useful if the same data is
used many times (eg: convert the data to C array in the constructor, and
then use it in all the methods).
-- 
Giovanni Bajo






More information about the Pyrex mailing list