[Python-ideas] Implicit submodule imports

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 26 23:35:10 CEST 2014


Steven D'Aprano wrote:

> By making importing automatic, every failed attribute access has to 
> determine whether or not there is a sub-module to import, which could be 
> quite expensive.

Another thing to consider is that code executed during an
import runs with the import lock held. This can lead to
surprises in multi-threaded code. I got caught out by it
once, and it took me a while to figure out what was going
on.

As long as the import lock exists, it's probably better
for importing to remain an eplicit action, at least by
default.

-- 
Greg



More information about the Python-ideas mailing list