[Pyrex] [Cython-dev] cdef private class ... ?

Stefan Behnel stefan_ml at behnel.de
Sat Jan 12 16:05:21 CET 2008


Hi again,

Stefan Behnel wrote:
> I was thinking about module namespace pollution a bit more. What about adding
> a class modifier "private" that keeps a class from appearing in the module
> dictionary?

I looked through the code to see how this would work. Apparently, all cdef
types and cdef functions in Pyrex/Cython *are* "private" by default
(entry.visibility). But only classes are exported to Python space. How's that
for consistency!

The visibility tag "public", on the other hand, is used to export the type
struct in a header file, "extern" is used for externally defined classes. The
last possible visibility tag then is "readonly", which doesn't seem to do
anything (or make any sense) for classes. I think that should actually raise a
compiler error (patch is attached).

So, although the parser currently forbids "private" as modifier, allowing
"private" won't work that easily. It would require making the default
visibility something like "normal", "python", or even None, which in turn
needs some attention at the places where the visibility is currently
evaluated. That's a pretty risky change, I guess. I still feel tempted to do
it. It just feels wrong to use the same default visibility for two different
things.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cdef-readonly-class-error.patch
Type: text/x-patch
Size: 1004 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20080112/f265eb8b/attachment.bin 


More information about the Pyrex mailing list