The descriptor protocol in Python 2.6 is only defined for class definitions, and thus can only be used by instances.
Is there some equivalent for instrumenting get/set of globals?
I'm trying to speed up the importing of a module which interacts with the host system, and as such has to perform some expensive probing of the host. The results of the (expensive) probe are stored in a module global that is initialized at import time; so I'm trying to delay the initialization until absolutely required.
Please, no comments about globals being evil. I know what they are and when to use them.
My current plan is to create a global instance that uses descriptors, and move all my current globals into the attributes of this instance. I expect this will work; I'm just asking if there's another way.