[Pyrex] [Cython-dev] Optimizing use of lists

Stefan Behnel stefan_ml at behnel.de
Tue Nov 27 09:35:00 CET 2007


Greg Ewing wrote:
> Robert Bradshaw wrote:
>> Great. I haven't started on this yet, so we should make sure to make  
>> things compatible.
> 
> I haven't thought it through in detail yet, but the
> plan is to pre-declare the main builtin types such as
> object, list, dict, tuple, etc. as though they were
> extension types, with appropriate methods.
> 
> I'll probably have to create a new kind of method so
> that things like some_list.append(foo) can be translated
> into a call to PyList_Append. Something like a non-
> virtual C method.
> 
> Something similar will also have to be done for type
> slots, so that some_list[i] can be translated into
> PyList_GetItem, etc.

Those would be real code beautifiers for me. lxml's code currently has 68
direct calls to PyList_Append(), most of them appear in functions that
construct a new list in a loop. I really hate writing that all the time, but
it makes a big difference in speed.

Stefan



More information about the Pyrex mailing list