[Python-Dev] Rethinking intern() and its data structure

P.J. Eby pje at telecommunity.com
Fri Apr 10 21:05:17 CEST 2009

At 06:52 PM 4/10/2009 +1000, Nick Coghlan wrote:
>This problem (slow application startup times due to too many imports at
>startup, which can in turn can be due to top level imports for library
>or framework functionality that a given application doesn't actually
>use) is actually the main reason I sometimes wish for a nice, solid lazy
>module import mechanism that manages to avoid the potential deadlock
>problems created by using import statements inside functions.

Have you tried http://pypi.python.org/pypi/Importing ? Or more 
specifically, http://peak.telecommunity.com/DevCenter/Importing#lazy-imports ?

It does of course use the import lock, but as long as your top-level 
module code doesn't acquire locks (directly or indirectly), it 
shouldn't be possible to deadlock.  (Or more precisely, to add any 
*new* deadlocks that you didn't already have.)

More information about the Python-Dev mailing list