I have a question about the semantics of mixing imports and cimports. I started drafting a long message with lots of details and examples, but I realized I should just start with a few simple questions: if you do
from Foo import Bar from Foo cimport Bar in a .pyx file, is it safe to assume that the Bar we import at runtime is going to be coming from the same module whose .pxd we analyzed at compile-time? Is it at least safe to assume that the Bar we import at runtime will be the same *type* as the Bar we saw at compile-time? (The next obvious question: what other information can we assume is the same?) Of course, this sounds reasonable enough, but completely goes against the usual Python import semantics, since there are so many ways to change what will actually get imported at runtime. In general, it would be nice (specifically as our type inferencer becomes more sophisticated) to be able to provide Cython with as much information as possible about the module it's going to see at runtime -- not just what's in the .pxd. In fact, if you know at compile-time which module is going to be there at runtime, it would be helpful to be able to tell Cython "here's the module, feel free to analyze it however you'd like." This makes sense even for import statements without a corresponding cimport. Would people be opposed to a "@cython.staticimport" decorator or the like? -cc _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
