> On 27 Jan 2022, at 07:46, Tony Flury wrote:
>
>
> On 26/01/2022 22:41, Barry wrote:
>>
>>
>> Run python and your code under a debugger and check the ref count of the
>> object as you step through the code.
>>
>> Don’t just step through your code but also step through the C python code.
>
On 26/01/2022 22:41, Barry wrote:
Run python and your code under a debugger and check the ref count of
the object as you step through the code.
Don’t just step through your code but also step through the C python code.
That will allow you to see how this works at a low level.
Setting a watc
> On 25 Jan 2022, at 23:50, Tony Flury wrote:
>
>
>
>
>> On 25/01/2022 22:28, Barry wrote:
>>
On 25 Jan 2022, at 14:50, Tony Flury via Python-list
wrote:
> On 20/01/2022 23:12, Chris Angelico wrote:
>>> On Fri, 21 Jan 2022 at 10:10, Greg Ewing
>>> wro
The convention for refcounting in CPython is that a function
takes borrowed references as arguments and returns a new
reference.
The 'self' argument passed in is a borrowed reference. If you
want to return it, you need to create a new reference by
increfing it.
So what you have written is just t
On 26/01/2022 08:20, Chris Angelico wrote:
On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list
wrote:
So according to that I should increment twice if and only if the calling
code is using the result - which you can't tell in the C code - which is
very odd behaviour.
No, the return valu
On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list
wrote:
>
> So according to that I should increment twice if and only if the calling
> code is using the result - which you can't tell in the C code - which is
> very odd behaviour.
No, the return value from your C function will *always* hav
On 26/01/2022 01:29, MRAB wrote:
On 2022-01-25 23:50, Tony Flury via Python-list wrote:
On 25/01/2022 22:28, Barry wrote:
On 25 Jan 2022, at 14:50, Tony Flury via
Python-list wrote:
On 20/01/2022 23:12, Chris Angelico wrote:
On Fri, 21 Jan 2022 at 10:10, Greg
Ewing wrote:
On 20/01/
On 2022-01-25 23:50, Tony Flury via Python-list wrote:
On 25/01/2022 22:28, Barry wrote:
On 25 Jan 2022, at 14:50, Tony Flury via Python-list
wrote:
On 20/01/2022 23:12, Chris Angelico wrote:
On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote:
On 20/01/22 12:09 am, Chris Angelico wrote:
On 25/01/2022 22:28, Barry wrote:
On 25 Jan 2022, at 14:50, Tony Flury via Python-list
wrote:
On 20/01/2022 23:12, Chris Angelico wrote:
On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote:
On 20/01/22 12:09 am, Chris Angelico wrote:
At this point, the refcount has indeed been increased.
> On 25 Jan 2022, at 14:50, Tony Flury via Python-list
> wrote:
>
>
>> On 20/01/2022 23:12, Chris Angelico wrote:
>>> On Fri, 21 Jan 2022 at 10:10, Greg Ewing
>>> wrote:
>>> On 20/01/22 12:09 am, Chris Angelico wrote:
At this point, the refcount has indeed been increased.
>
On 20/01/2022 23:12, Chris Angelico wrote:
On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote:
On 20/01/22 12:09 am, Chris Angelico wrote:
At this point, the refcount has indeed been increased.
return self;
}
And then you say "my return value is this object".
So you're incre
On Fri, 21 Jan 2022 at 10:10, Greg Ewing wrote:
>
> On 20/01/22 12:09 am, Chris Angelico wrote:
> > At this point, the refcount has indeed been increased.
> >
> >> return self;
> >> }
> >
> > And then you say "my return value is this object".
> >
> > So you're incrementing the refco
On 20/01/22 12:09 am, Chris Angelico wrote:
At this point, the refcount has indeed been increased.
return self;
}
And then you say "my return value is this object".
So you're incrementing the refcount, then returning it without
incrementing the refcount. Your code is actually
> On 19 Jan 2022, at 10:57, Tony Flury via Python-list
> wrote:
>
> I am writing a C extension module for an AVL tree, and I am trying to ensure
> reference counting is done correctly. I was having a problem with the
> reference counting so I worked up this little POC of the problem, and I
On Thu, Jan 20, 2022 at 1:22 AM Tony Flury wrote:
>
>
> On 19/01/2022 11:09, Chris Angelico wrote:
> > On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list
> > wrote:
> >> Extension function :
> >>
> >> static PyObject *_Node_test_ref_count(PyObject *self)
> >> {
> >> p
On 19/01/2022 11:09, Chris Angelico wrote:
On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list
wrote:
Extension function :
static PyObject *_Node_test_ref_count(PyObject *self)
{
printf("\nIncrementing ref count for self - just for the hell
of it\n");
On Wed, Jan 19, 2022 at 10:00 PM Tony Flury via Python-list
wrote:
> Extension function :
>
> static PyObject *_Node_test_ref_count(PyObject *self)
> {
> printf("\nIncrementing ref count for self - just for the hell
> of it\n");
> printf("\n before self has a ref coun
I am writing a C extension module for an AVL tree, and I am trying to
ensure reference counting is done correctly. I was having a problem with
the reference counting so I worked up this little POC of the problem,
and I hope someone can explain this.
Extension function :
static PyObject *_N
18 matches
Mail list logo