[Python-Dev] properties on modules?

Just van Rossum just@letterror.com
Mon, 13 Jan 2003 22:03:19 +0100


Guido van Rossum wrote:

> I still don't see the use case for late binding of module attributes.

The PyObjC project (the Python <-> Obective-C bridge) has/had a problem
which might have been solved with lazy module attributes: one module can
export a *lot* of ObjC classes, and building the Python wrappers takes
quite a bit of time (at runtime), so much much it was quite noticable in
the startup time, which especially hurt small apps. At some point I even
suggested to insert an object with a __getattr__ method into
sys.modules(*), but in the end some other optimizations were done to
make importing somewhat quicker.

*) I was pleasantly surprised how seamless that actually works: as long
as the object either has an __all__ or a __dict__ attribute everything
seems to work just fine. So if you *really* want lazy attributes, you
can get them...

Just