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

Stefan Behnel stefan_ml at behnel.de
Fri Jan 11 18:04:27 CET 2008


Hi,

Kay Hayen wrote:
> Am Donnerstag 10 Januar 2008 18:45:44 schrieb Stefan Behnel:
>> 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 considered "static", which is the C equivalent, but since that has a
>> totally different meaning in another C-like big-buzzword coffee-language, I
>> prefer "private" here, which I find much more explicit.
>
> as a quick way, I would suggest to have names with "_" assumed to be local
> to the module and not for export.

That could be taken as a convention, however, in Python, these classes/names
still show up in the module dictionary and form sort of a semi-public API that
you /can/ use if you know what you are doing. So letting Cython discard them
from the module namespace automatically would be unexpected at best.

You could argue the same way for "__ClassName", but that's still not explicit
enough IMHO.


> Generally speaking, I rather use a syntax to decorate the class with a
> suggested CompilerHints module. This has the advantage that the syntax
> remains pure Python.
>
> @CompilerHints.static
> class ....
>
> As I said before, I see no reason for compiler hints not to be pure Python.

It's not just a "compiler hint", it's a different thing than a normal, module
exported class. I think syntax makes sense here given the general language
semantics of Cython/Pyrex.

Stefan



More information about the Pyrex mailing list