Stefan Behnel, 09.01.2010 21:06:
> borrowed_ref = []
>
> The above could raise an error at compile time, and I actually think that
> we could use the same mechanism as for e.g. bytes->char* conversions of
> temporary values to detect incorrect code.
Thinking about this some more, 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*").
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev