[Pyrex] C-API implementation in Pyrex 0.9.6

Stefan Behnel stefan_ml at behnel.de
Sat Oct 20 08:51:02 CEST 2007


Greg Ewing wrote:
> # export.pxd
> 
> cdef struct Foo:
>   int spam
> 
> # importer.pyx
> 
> cimport package.export
> cimport export
> 
> def test():
>   cdef package.export.Foo a
>   cdef export.Foo b
>   a = b

Ok, this may be a problem if you accidentally use different imports in a .pxd
and a .pyx file, but Pyrex would find that problem at compile time, I imagine.

I do not think that this is a problem in practice. You would rarely use
different import schemes for the same module *inside* one module. And if you
ever do that, I wouldn't mind getting errors because of that. After all,
cimports are a compile time thing in Pyrex, not a dynamic thing. I even find
it bad style to import a module in different ways inside the same source
context. Pyrex shouldn't encourage bad style and I think package local imports
are much more common than the problem you construct above.

Stefan



More information about the Pyrex mailing list