Dag Sverre Seljebotn, 25.01.2010 10:17: > Stefan Behnel wrote: >>> [...] why not just represent a borrowed reference as a pointer? >>> So you could write >>> >>> cdef list some_list = [] >>> cdef list* borrowed_ref = some_list >>> >>> and borrowed_ref would be a non-refcounted pointer to a Python list. >>> Assignments back to a normal reference would be allowed: >>> >>> cdef list my_list = borrowed_ref # increfs the pointer >>> >>> After all, a non-refcounted reference to a Python object is not more than a >>> bare pointer to a well-defined Python builtin/extension type (including >>> "object*"). > > Well, there's the drawback of making the language more complicated, and > also I think the notation is confusing -- plain "object" is not by > value, and "object*" is not a pointer to an "object", so to speak.
I was trying to let the syntax emphasise that it *is* a pointer, not a reference. A reference is special in Cython in that it handles ref-counting for it. A pointer just behaves like any other pointer in the language. I agree that it's not flawless, but I think it makes sense and is unambiguous. > How about a set of explicit functions like > > cdef object x = skip_incref(PyTuple_GET_ITEM(t, 0)) I don't think that fits the use case very well. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
