[Zope-dev] _getOb or __getattr__?

Shane Hathaway shane@digicool.com
Wed, 07 Mar 2001 09:49:09 -0500


Chris Withers wrote:
> 
> > subobjects because acquisition only looks at object attributes.  It
> > doesn't know anything about _getOb().  (And it's not a good idea to
> > teach it to use _getOb(); think what it would be like if a Xeon ran like
> > a 386...)
> 
> I remember the days when... ;-)
> 
> Seriously though, why would that make it so slow? Is _getOb() often an
> expensive operation?

No.  The expensive part is invoking Python code from C.  It's the same
problem described by the documentation for the Python sort() method:
it's much faster to sort() then reverse() than it is to sort() with a
comparison function that reverses the elements.  Invoking C from Python
is fast, but invoking Python from C apparently requires a lot of work.

Shane