[Python-Dev] A bit faster access to module attributes
Guido van Rossum
Tue, 01 Jul 2003 12:27:46 -0400
> >>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
> PyObject_GetAttr, object.c,eval.c).
> 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).
Doesn't strik me as time-critical.
> >>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.
--Guido van Rossum (home page: http://www.python.org/~guido/)