This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients brett.cannon, pitrou
Date 2012-02-17.18:57:22
SpamBayes Score 8.710268e-08
Marked as misclassified No
Message-id <1329505043.59.0.00908460651778.issue14043@psf.upfronthosting.co.za>
In-reply-to
Content
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. =)
History
Date User Action Args
2012-02-17 18:57:23brett.cannonsetrecipients: + brett.cannon, pitrou
2012-02-17 18:57:23brett.cannonsetmessageid: <1329505043.59.0.00908460651778.issue14043@psf.upfronthosting.co.za>
2012-02-17 18:57:22brett.cannonlinkissue14043 messages
2012-02-17 18:57:22brett.cannoncreate