On Fri, May 09, 2008 at 02:13:21PM +1200, Greg Ewing wrote:
> I've been thinking some more about __getattribute__, and I think
> that rather than trying to emulate the Python semantics, the
> right thing to do is simply to expose the C type slot directly.
> 
> This would be in keeping with the way the other type slots
> are handled. The philosophy is that when defining an extension
> type, you should have as much control and as little overhead
> in the way as possible.
> 
> The only places where I've done things differently are where
> there isn't a directly corresponding C slot, such as __getattr__.
> Since __getattribute__ corresponds most closely to tp_getattr,
> it should just fill it directly.

If no __getattr__ is defined, __getattribute__ is essentially a
tp_getattr slot filler:

static PyObject *__pyx_tp_getattro_3foo_foo(PyObject *o, PyObject *n) {
    PyObject *v = __pyx_pf_3foo_3foo___getattribute__(o, n);
    return v;
}

One level of indirection, but that's just an artifact of the current
implementation that the compiler might very well optimize out anyway.

-- 
http://petertodd.org 'peter'[:[EMAIL PROTECTED] 

Attachment: signature.asc
Description: Digital signature

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

Reply via email to