Brett Cannon <br...@python.org> added the comment:

OK, I have gone ahead and done a review over on rietveld for the code as-is. 
But I do have a design question.

Why pre-calculate everything? In the most common case any single module will be 
imported once, if at all. And once it is imported it will get cached in 
sys.modules, alleviating the need to hit the finder again. So from a 
performance standpoint wouldn't it be better not to do all of the 
pre-calculation and instead do that as needed assuming that sys.modules will 
shield the finder from having to do repetitive things like figuring out what 
loader is needed? You will have to do the calculation regardless for the first 
import, but you might not need to import every module in a directory. Plus if 
the finder gets its cache invalidated frequently it  will simply be wasting its 
time.

I'm not going to argue from the perspective that most modules won't get 
imported as that's purely a stdlib thing; I am willing to bet most projects 
import nearly all of their modules in each execution.

Otherwise it's good to know three of us now have independently come up with 
fundamentally the same idea for speeding up imports. =)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14043>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to