On May 8, 2008, at 7:13 PM, 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.

I think this is a philosophical difference between Cython and Pyrex-- 
in Cython we want to stick to Python semantics as closely as possible  
so the user doesn't even have to think about whether they're writing  
an extension class or not. Eventually one should be able to take  
any .py file, run Cython on it, and have it behave exactly the same.  
If this is not the case than it is a bug. (I'm not sure exactly what  
to do about arithmetic though--that might be one exception.)

> 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.

In terms of efficiency, __getattribute__ is called at the top, and on  
success tp_getattr returns immediately, so it should be just about as  
fast.

- Robert

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

Reply via email to