Hi Lisandro,

thanks for doing this!

Lisandro Dalcin wrote:
> 1) You have a 'cython.py' script. This script just add 'set' and
> 'frozenset' to __builtin__ module for the case of Python 2.3.

IMHO, the compiler shouldn't mingle with __builtins__, so this must be handled
directly in Cython as a special case.


> 2) Place the files 'py23sets.h' and 'py23sets.pxd' as apropriate in
> your source tree. Then all what you need to do is the following: near
> the beginning of your pyx module sources, add these two lines:
> 
> cimport py23sets
> py23sets.install()

I think the #ifdef depending on the Python header file rather than the Python
version makes sense here, although an additional check for Py2.4+ would be
more future proof. Header barriers aren't necessarily what one would call a
public feature.

However, Cython should generate the respective code into the C file body and
the call to the install() function into the module init function - iff the
set/frozenset builtin types were used in the code. This can use the normal
utility code machinery.

I also don't think we need any special __Pyx_*() naming here. Just name the
functions after their Python 2.4+ counterparts and skip the function pointer
assignments in the setup function.

Also, you can replace some more of the functions by plain macros, such as

        #define PySet_Size(anyset) PyObject_Size(anyset)
        #define PySet_Pop(set) PyObject_CallMethod(set, "pop", NULL)

If nothing else, this reduces at least the legacy code overhead in the
generated C file.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to