On Sat, Oct 25, 2008 at 6:14 AM, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> 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.

Yep, but I had to do that for the special casing n Builtins.py

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

Of course. Take into account that I wrote all that in 10 minutes ;-)

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

Of course, this is the right way.

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

Well, I always try to avoid function-like macros at all. Why? Just
because a macro is not a function, you cannot take a pointer to the
function. If we also want Cython code to access the C-API for sets,
then we should be able to to

in (*funcptr)(PyObject*) = PySet_Size;

and now call funcptr(anyset).



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to