Hi,

Robert Bradshaw wrote:
>>   // --- FILE defs.h
>>   #define PY_NEW(T) \
>>        (((PyTypeObject*)(T))->tp_new( \
>>                (PyTypeObject*)(T), __pyx_empty_tuple, NULL))
> 
> One would declare the type object as having a function pointer field
> tp_new with the right signature. (In fact, when we support
> builtin-types, this should be available by default at T.tp_new((), NULL)).

Ok, I like that.


>>   # --- FILE some.pyx
>>   cdef extern from "defs.h":
>>       # macro call to 't->tp_new()' for fast instantiation
>>       cdef DTD NEW_DTD "PY_NEW" (object t)
>>
>>   dtd = NEW_DTD(DTD)
> 
> This can only be done because one is dealing with two separate namespaces.

Which was part of my proposal.


> I do think there are valid uses for C macros/arbitrary C in some Cython
> code. I also hope that the need for such special use cases goes down as
> Cython improves. But if one wants to muck around with stuff like this I
> think one should write an actual .c or .h file and include stuff from
> there, rather than provide an easy (and IMHO ugly) way to embed raw C
> code strings in Cython files.

Admittedly, that's only one more file to keep track of, and you might need it
anyway...

Stefan

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

Reply via email to