[Python-Dev] properties on modules? (original) (raw)

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