[Python-Dev] Autoloading? (Making Queue.Queue easier to use)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 12 03:26:58 CEST 2005


Guido van Rossum wrote:

> I see no need. Code that *doesn't* need Queue but does use threading
> shouldn't have to pay for loading Queue.py.

However, it does seem awkward to have a whole module
providing just one small class that logically is so
closely related to other threading facilities.

What we want in this kind of situation is some sort
of autoloading mechanism, so you can import something
from a module and have it trigger the loading of another
module behind the scenes to provide it.

Another place I'd like this is in my PyGUI library,
where I want all the commonly-used class names to appear
in the top-level package, but ideally not import the
code to implement them until they're actually used.

There are various ways of hacking up such functionality
today, but it would be nice if there were some kind of
language or library support for it. Maybe something like
a descriptor mechanism for lookups in module namespaces.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list