On Tue, 25 Jan 2005 00:30:44 +0100, "Martin v. Löwis"
<[EMAIL PROTECTED]> wrote:
> Neal Norwitz wrote:
> >>Where are the Py_DECREFs done for the function arguments?
> >
> > The original code path still handles the Py_DECREFs.
> > This is the while loop at the end of call_function().
> 
> Can you please elaborate? 

I'll try.  Do you really trust me, given my first explanation was so poor? :-)

EXT_POP() modifies stack_pointer on the stack.  In call_function(), 
stack_pointer is PyObject ***.  But in new_fast_function(), stack_pointer
is only PyObject **.  So the modifications by EXT_POP to stack_pointer
(moving it down) are lost in new_fast_function().  So when it returns
to call_function(), the stack_pointer is still at the top of the stack.
The while loop pops off the arguments.

If there was a ref leak, this scenario should demonstrate the refs increasing:

>>> isinstance(5, int)
True
[25363 refs]
>>> isinstance(5, int)
True
[25363 refs]
>>> isinstance(5, int)
True
[25363 refs]

The current code is not optimal.  new_fast_function() should take PyObject***
and it should also do the DECREF, but I had some bugs when I tried to get
that working, so I've deferred fixing that.  It ought to be fixed though.

HTH,
Neal
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to