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

Stefan Behnel stefan_ml at behnel.de
Wed Jan 30 10:59:46 CET 2008


Hi,

Robert Bradshaw wrote:
> On Jan 29, 2008, at 11:38 PM, Stefan Behnel wrote:
>> Greg Ewing wrote:
>>> Stefan Behnel wrote:
>>>> I would really like to have something like this.
>>>
>>> The main thing that worries me is the cimport issue --
>>> if you remove the module dict entry, then other Pyrex
>>> modules (and any other C-implemented modules, for that
>>> matter) are prevented from accessing the type as well.
>>> This applies regardless of whether it's done by a keyword
>>> or by del.
>>
>> Not quite, if you use a keyword (or modifer), you could check at
>> compile time
>> that the type does not appear in the associated .pxd, i.e. that it
>> cannot be
>> cimported.
> 
> What you're saying is that you would disallow cimporting a "private"
> type? Then this might work...

Actually, you could still allow that for the C-API, which could add public
types to the "_pyx_capi" dict (which currently only contains C function
pointers), and then have external modules import them from there instead of
the module dict. But then, a 'public private' type looks kind of scary. Maybe
a 'private api' type would match this use case...

Anyway, I'd be fine with making 'private' types really internal to the module,
including "no cimports".


> While we're on the topic of visibility, what would you think about
> making any cdef function declared in a pxd file "cimportable" (i.e.
> public api, or whatever the keyword combination is--I'm never quite
> sure). This is the only reason one would put a cdef function in a .pxd
> file.

I'll leave this question to Greg, I'm not familiar enough with the current
mechanisms here.

Stefan



More information about the Pyrex mailing list