On Thu, Jul 9, 2009 at 15:20, Fons Adriaensen<f...@kokkinizita.net> wrote:
> On Thu, Jul 09, 2009 at 12:00:23PM -0500, Robert Kern wrote:
>
>> On Thu, Jul 9, 2009 at 11:44, Fons Adriaensen<f...@kokkinizita.net> wrote:
>>
>> > There is a simple rule which says that if you use an object
>> > pointer as a function argument you must INCREF it. This is
>> > just the logical consequence of using refcounted objects.
>>
>> That's not true. There are many functions even in the standard Python
>> C API that "borrow" a reference.
>
> Indeed. Still, when calling a function Python will
> INCREF the arguments. And that's only logical since
> these arguments become local variables (i.e. a new
> reference) inside the called function and that function
> can do whatever it wants with them, including deleting
> or re-assigning them. Creating a function argument is
> not different from assigning to a new variable.
> This is also the reason why sys.getrefcount() will return
> a value that is one higher than the one in the caller's
> context.

That's not quite true. Forming the argument tuple increments the
count, not the call itself.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to