>> Dag Sverre Seljebotn wrote: >>> Allocation would happen through an actual (as light-weight as >>> possible, and probably mostly opaque, perhaps doing as much as printing >>> the C++ name of the class in its repr) Python object >> >> That wouldn't work, though. Imagine you'd return the C++ object pointer >> from a function. What would happen to the Python object that holds it? >> How >> would you keep the ref-counting context for it? > > There would be no coercion between pointers and refcounted variables. I.e. > if you have > > cdef extern CppObject* foo() > > you can NOT do > > cdef CppObject obj = foo() > > It would only work when C++ returned an object *by value*:
The deeper point here is that Cython has no concept of objects by value, which C++ has, and I'm trying to avoid that from creeping in. For instance you have CppObject a, b; b = a; a.set_foo(4); // does not set foo of b which would look strange in Cython. So I have two goals: - convenient STL iterator syntax - avoiding the above semantics in Cython and everything else, though it might seem complicated, kind of flows from that (and it's not hard to implement). Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
