[Pyrex] C-API implementation in Pyrex 0.9.6

Stefan Behnel stefan_ml at behnel.de
Wed Oct 17 10:01:00 CEST 2007


Greg Ewing wrote:
> Stefan Behnel wrote:
>> I also think that Pyrex should not re-import a module for each type it
>> wants
>> to cimport from it, but rather import each required module once,
> 
> Are you sure that's really worth the effort? Re-importing
> an already-imported module is pretty cheap, since you're
> just pulling it out of sys.modules, and the code in
> question is only executed once when the importing module
> is loaded.

I'm not so much worried about the runtime overhead. But the import code gets a
bit more complex now and uses a fallback, so doing it once and then referring
to a variable makes the code more readable and less error prone here - if the
import succeeds once, we're done.

Stefan




More information about the Pyrex mailing list