On Tue, Aug 17, 2010 at 6:25 PM, Carl Witty <[email protected]> wrote:

> I'm really quite sure that the performance bug was due to a
> Cython-created __getattr__ wrapper.
>
> In detail: when you create a non-cdef subclass of a cdef class with
> __getattr__, Python has to decide what to stick in the tp_getattro
> slot.  It notices that there's a __getattr__ defined (that's not a
> Python-created wrapper object), and so it puts in a generic function
> that looks up __getattribute__ and __getattr__ in the type dictionary.
>
> I guess copying __getattribute__ to __getattr__ would slightly change
> the behavior when somebody accessed __getattr__ directly.  (It
> wouldn't change the behavior of normal attribute lookup on the
> object.)
>
> With the current cython-devel we could probably fix the Sage
> __getattr__ performance issue by changing Parent and Element to define
> __getattribute__ instead of __getattr__.  (Maybe this is what you were
> saying?)

No, defining __getattribute__ is much worse than defining __getattr__
because then it needs to call __getattribute__ as an opaque Python
function before invoking the standard Python lookup mechanisms.

Really, I just need to read some code and do some benchmarks.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to