[Pyrex] Question, plus suggestions for improvement?

Bill Mill bill.mill at gmail.com
Wed Aug 2 00:50:29 UTC 2006


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

While very interesting, I won't copy the thread between you and
Josiah. Instead, I'll give you both some more requirements.

Since the size of the input list is limited severely by practical
concerns (it has factorial(len(input_list)) permutations), my problem
is largely one of many array accesses.

Would it be better to convert the list into a C array? How should I do
so? I assume I'll need to convert it back to a python array when I'm
done - is that going to kill any performance gains I may see inside
the main loop? (Well, if you answer the second question, I'll just
experiment and answer the third for you.)

Peace
Bill Mill
bill.mill at gmail.com



More information about the Pyrex mailing list