Robert Bradshaw | 1 Feb 20:31
Favicon

Re: [Cython] Support for borrowed references

On Feb 1, 2010, at 6:37 AM, Dag Sverre Seljebotn wrote:

> Stefan Behnel wrote:
>> 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.
>>>
(Continue reading)


Gmane