On Sep 1, 2008, at 12:13 PM, Stefan Behnel wrote:

> Hi,
>
> Hoyt Koepke wrote:
>> One of my main questions when I initially thought about it is how to
>> handle the operator methods in c++.  When I define __getitem__, I  
>> have
>> to define it as a python function using def, so is it compiled
>> directly into c code? To ask it another way, is there any way to
>> create a class A such that I can write
>>
>> a = A(...)
>> a[i] += 1
>>
>> and have the a[i] += 1 be entirely c(++) code?
>
> Yes, but within the limits of the Python getitem protocol. This  
> means that the
> item itself will be a Python object, and thus the "+= 1" will be  
> executed on
> two Python objects.

One *can* get around this with the buffer interface however.

- Robert

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

Reply via email to