Chris Colbert wrote: > for example if I have something like this: > > cimport numpy as np > > cdef void foo(np.ndarray arr): > <do stuff> > > > def bar(np.ndarray arr): > foo(arr) > > > is arr getting passed by value or by reference? > It's passed like any Python object, which is to say, by reference. Python objects are *always* passed by reference.
> When I wrap other C libraries, I have to do a foo(&cobject) to pass > cobject by reference and have foo defined as: > > cdef foo(somectype* cobject): > cobject.intvalue = 3 > > > The reason I ask is because even though i'm not explicity passing the > numpy arrays by reference, I can still access the struct memember via > dotted notation (arr.strides[2] for example). Since Cython doesnt have > a -> operator, its not exactly clear what is going on here in this > situation. > Cython translates x.y to -> when x is either a typed Python extension type or a pointer, and keeps it as "." for a struct. This is less than ideal for speaking with C++ but keep in mind that Cython/Pyrex was designed for C where this simplification could be made. Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
