From: Richard Ward <richard.j.ward1@googlemail.com>
To: archer@sourceware.org
Subject: Re: [RFC][2/5] Event and event registry
Date: Wed, 23 Sep 2009 23:28:00 -0000 [thread overview]
Message-ID: <4ABAAF04.4020608@googlemail.com> (raw)
In-Reply-To: <m3eiq0x8sa.fsf@fleche.redhat.com>
Tom Tromey wrote:
>>>>>> "Oguz" == Oguz Kayral <oguzkayral@gmail.com> writes:
> Oguz> Py_INCREF (func);
> Oguz> PyList_Append (callback_list, func);
>
> I always forget whether the list APIs incref themselves, or not.
As a general rule, The list/dict/tupe functions do their own
incrementing (so the Py_INCREF above is not needed).
The main Exceptions are Py(List|Tuple)_SetItem, which steal a reference.
The idea being if you create a sequence with Py(List|Tuple)_New(length)
with length>0, you are probably going to create a bunch of objects to
put in the list. The stealing of references mean you don't have to call
Py_DECREF after each Py(List|Tuple)_SetItem (but you must own a `spare'
reference when you do it).
FWIW there seem to be a fair few places in gdb where Py_INCREF is used
over-zealously. Sometimes this is just extra increments to python's
None, True and False values, which I suppose won't cause any leaks, but
there are a few places that will.
Richard.
next prev parent reply other threads:[~2009-09-23 23:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-23 15:35 Oguz Kayral
2009-09-21 21:55 ` Tom Tromey
2009-09-23 23:28 ` Richard Ward [this message]
2009-09-25 18:37 ` Tom Tromey
2010-02-05 11:12 ` Oguz Kayral
2010-02-05 11:31 ` [Archer] " Joel Brobecker
2010-02-10 22:45 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ABAAF04.4020608@googlemail.com \
--to=richard.j.ward1@googlemail.com \
--cc=archer@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).