[Pyrex] Pyrex optimization
Paul Prescod
paul at prescod.net
Tue Jan 13 20:53:33 CET 2004
I've done some experiments with getting Pyrex to generate fast code
(comparable with hand-written C code) and written up some techniques:
http://www.prescod.net/python/pyrexopt/optimization.html
The basic conclusions are
a) your Pyrex code can live on a spectrum from very readable to
very-fast but it is hard to get 100% of both.
b) Pyrex should be smarter about using PySequence_GetItem and
PyList_GETITEM etc. when they are appropriate rather than always
PyObject_GetItem. (and of course similar issues for SetItem and
DelItem). At least some of this can be pretty easily done merely by
adding "sequence" and "list" types along with the basic "object" type.
Alternate strategies could be type inferencing, type hinting, runtime
specialization, etc. Whatever: the function calls need to be type specific.
Paul Prescod
More information about the Pyrex
mailing list