[Pyrex] C-API implementation in Pyrex 0.9.6

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 20 12:47:38 CEST 2007


Stefan Behnel wrote:
> 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.

Not necessarily. If the types involved are extension
types, Pyrex won't complain, but it will generate a lot
of unnecessary type tests, because it thinks the types
are unrelated.

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

It doesn't have to be inside one module. Suppose module
A defines a type X, and module B imports X and uses it
in the definition of another type Y. Now module C imports
both X and Y. It shouldn't have to know or care exactly
how B got hold of its version of X.

> And if you
> ever do that, I wouldn't mind getting errors because of that.

The errors you get could be quite mysterious and difficult
to track down. You might be happy to get that kind of
error, but I wouldn't.

> Pyrex shouldn't encourage bad style and I think package local imports
> are much more common than the problem you construct above.

What about imports from modules which aren't in the package?
The only way to fix this by style enforcement would be to
ban local cimports altogether and require all cimports to
be absolute.

--
Greg



More information about the Pyrex mailing list