[Pyrex] Pyrex optimization

Jiba jiba at tuxfamily.org
Wed Jan 14 13:41:03 CET 2004


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

I have arrived to similar conclusion, and i was wondering if it would be
possible to "import" in Pyrex the list and dict classes/types, e.g. from
python.h

In addition to sequences and lists, i believe that tuples and dicts can
be usefull too. Though such types should be used ONLY when you are 100%
SURE that the object IS REALLY a list / dict /... (i.e. when the object
is created in Pyrex); e.g. someone may use the bisect module on non-list
object, but on object that behave like a list (like UserList).

So the obfuscated Pyrex version of bisect would break backward
compatibility, IMHO.

Jiba




More information about the Pyrex mailing list