On Sep 1, 2008, at 11:56 AM, Hoyt Koepke wrote:

> Hi,
>
>> That would be excellent! It would necessitate using C++, which is not
>> going to be the default Cython output but would be very hand for
>> people wanting to use it.
>
> Okay, encouragement is a good motivator.  I'll try to get to it.
>
> 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?

Yes. To clarify, the bodies of def methods are compiled into C code  
just as with cdef methods, and special methods are special, meaning  
the get called as C functions via the Python/C API, so they are not  
really "def" methods but nor are they really "cdef" methods.

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

Almost. One can use the buffer interface for the class A, then use  
the "operator overloading" trick at the bottom of http:// 
wiki.cython.org/WrappingCPlusPlus. (Of course this still has a level  
of indirection). Being able to do this directly without a wrapper  
would be very nice...and probably not too hard either.

>> Another option would be something like http://wiki.cython.org/
>> enhancements/arraytypes, though this is probably further off in the
>> future than wrapping several C++ containers.
>
> Okay, I'll look into it.  Thanks.

On this note, it would be good to come up with better support for  
wrapping templated libraries.

>
> -- Hoyt
>
> P.S.  Robert -- I see you're at UW.  I'm starting a PhD in stats there
> in a few weeks.  Just down the hall from the math department, IIRC.
> I'll drop by some time and say hi.

Neat. There's a lot of other Cython (Sage) folks around the math  
department there too.

- Robert


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

Reply via email to