[Python-Dev] A bit faster access to module attributes
Wiktor Sadowski" <email@example.com
Tue, 1 Jul 2003 18:25:51 +0200
>>Have you found any situation where this particular operation was
Each time a module's attribute is accessed with:
from module import attr or module.attr
a routine assigned to module tp->getattro is called (through
Is it time-critical? As for small Python applications, no.
However it probably could help in case of monsters like wxPython or Zope.
(improving the applications startup performance as well).
>>I believe (without thinking it through in detail) that the generic
>>getattr/setattr routines are required in order to support subclassing
>>of modules, which people use.
Adding tp->tp_dict check->PyType_Ready-call to suggested new
getattr/setattr routines wouldn't hurt much so subclassing could/will work,
while "regular" modules could still benefit from suggested changes.
>>So I think your suggestion cannot work, and I also think it is
>>unnecessary, so I don't believe it is worth the bother.
It works (tested). I wouldn't bother you otherwise.
Well, all this is doable from a C extension module,
so yes, modifying moduleobject.c is unnecessary.
Sorry for taking your time.