[Cython] namespacing external declarations (was: [cython-users] Calling C++ functions without headers.)

Stefan Behnel stefan_ml at behnel.de
Sun Jan 20 07:57:33 CET 2013


John Tyree, 20.01.2013 04:11:
> On Fri, Jan 18, 2013 at 10:54:24AM -0800, Robert Bradshaw wrote:
>> On Fri, Jan 18, 2013 at 8:21 AM, John Tyree wrote:
>>> There's no way to have namespaces come over with the function names is there?
>>>
>>> cdef extern from "b.cpp" namespace "foo":
>>>     void whatever()
>>>
>>> and then use foo.whatever() instead of just whatever()? I guess using a new pxd
>>> for each namespace and then cimport namespace is the best solution to that problem.
>>
>> Yep. We could consider adding a "as XXX" clause to extern inport
>> blocks as well.
>
> The as XXX alias on cdef extern from ... blocks would be seriously great. Would
> it be difficult?

I'm -0.7 on this. It would divert from Python in that you'd get yet another
way to provide a namespace inside of one source file. It won't come for
free in terms of compiler code complexity. And I don't see the big win over
having one .pxd file per namespace that you declare. That's what files are
there for, after all. And it works the same in both Python and Cython,
right now.

Stefan



More information about the cython-devel mailing list