[Pyrex] A couple of questions about pyrex
Robert Bradshaw
robertwb at math.washington.edu
Tue May 12 20:54:28 CEST 2009
On May 12, 2009, at 9:15 AM, Franck Pommereau wrote:
>> Think further down the road after that is done,
>> if some day we decided to use 'cdef class' for
>> private class definitions
>
> I don't think that cdef should be interpreted as private. But it means
> that what follows is a native object (ie, implemented in C) instead
> of a
> Python object.
+1
> So if you cdef a type, a variable or a function, there is no way to
> access it from Python because C and Python have different conventions
> for such objects (eg, Python uses name bindings in environment and has
> no proper notion of variable, and calling conventions are different
> also).
>
> On the other hand, if you cdef a class, there is no way to see it as a
> class from C because there is no such notion here. But anyway you
> get a
> class implemented in C, which is considered a builtin class by Python.
>
> Presented this way, it looks fully consistent (at least to me).
cdef statements are used in a variety of declaration scenarios (cdef
classes, cdef extern blocks, cdef variables and methods) and I think
the best way to think about them is "something at the C level is
going on here." In any case, the current syntax is not going away/
changing meaning if just for backwards incompatibility reasons. Also,
the distinction between classes and types is still large enough that
on needs to distinguish them, and "explicit is better than implicit."
- Robert
More information about the Pyrex
mailing list