[Pyrex] A couple of questions about pyrex

Stefan Behnel stefan_ml at behnel.de
Wed May 13 07:08:14 CEST 2009


[and to the list...]

Yingjie Lan wrote:
> --- On Wed, 5/13/09, Robert Bradshaw wrote:
>> But cdef already has a (widely used) meaning.
> 
> That's true, and cdef defines something invisible
> to python except for the 'cdef class', according
> to my knowledge from the language documentation.
> But correct me if I am wrong.

We did.


>> It seems "private class" would be more ideal,
>> which could apply to  
>> cdef classes, non-cdef classes, and all other kinds of
>> declarations.

... problem being that "private" is used internally as opposite of
"public", which is the main reason why a private-class syntax is not trivial.

Apart from that, explicit is better than implicit, so "private class" makes
a lot more sense than a plain "cdef class".


> I would not recommend 'private class' for two reasons:
> 
> 1. If you use 'private', then you might also use 'public',
> etc, which makes things complicated.

No, a public class is well defined in Pyrex/Cython. You can read up on that
in the docs.


> 2. Here we are actually not talking about a 'privateness'
> in the broad sense, but rather in a very very specific 
> sense: that is, only private to python. Such a private
> class may still be visible in pyrex code/file.

Actually, the answers you got so far were "very specific" and based on
internal knowledge of the compiler.


> So, how do we achieve that? The answer is already there,
> exactly the same way we distinguish 'cdef' and 'def' 
> for function declarations. 'def' declare a function
> visible to python, while 'cdef' declares an invisible one.

Visibility and Python/C-level definition are orthogonal concepts.

Stefan





More information about the Pyrex mailing list