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

Robert Bradshaw robertwb at math.washington.edu
Wed Jan 30 11:06:08 CET 2008


On Jan 30, 2008, at 1:59 AM, Stefan Behnel wrote:

> 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".

That'd certainly be much simpler. I don't think I'd ever personally  
use the functionality either way though.

>> 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.

I know how to do it (that's easy enough), it's a question of whether  
or not you think it's a good idea. I think it is.

- Robert




More information about the Pyrex mailing list