Hi, Lisandro Dalcin wrote: > On Sat, Oct 25, 2008 at 6:14 AM, Stefan Behnel wrote: >> 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.
I'm only -0.5 for the macro version anyway, but I doubt that that's a common use case. Plus, it only affects Py2.3 and partially Py2.4. I'm pretty sure, anyone who wants to do fancy stuff with the set API will require Py2.5 anyway, where this API was first made public. > 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). I don't see why that's necessary. PySet_Size() will be defined (as function or macro) for the user code, regardless of the Python version, and it thus callable from Cython code once it's defined in a cimported .pxd file. BTW, PySet_Size is a particularly bad example, as it's likely not much faster than calling len() anyway. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
