Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8


devel / comp.lang.python / Re: Cpython: when to incref before insertdict

SubjectAuthor
o Re: Cpython: when to incref before insertdictMarco Sulla

1
Re: Cpython: when to incref before insertdict

<mailman.207.1646582892.2329.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21808&group=comp.lang.python#21808

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Sulla.Python@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: Cpython: when to incref before insertdict
Date: Sun, 6 Mar 2022 17:07:33 +0100
Lines: 16
Message-ID: <mailman.207.1646582892.2329.python-list@python.org>
References: <CABbU2U8d9scJo8pMaynoW25jmT-ipJc9DMfbEy2ccmEsr1GK7w@mail.gmail.com>
<CAEfz+TwbRyfhNqjnd4MJgFjk8kK3_q2otNxEoah9eytu=C49yg@mail.gmail.com>
<CABbU2U-uByMD0nNH_2TyZZdqGzWiQ5k7fmb-NwettzDx=ouM=w@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de JZbPOUCTIze7n6WelRBf/AOySq76S4jKFTQLRqeIjUsQ==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=cY/5xxcZ;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82/16': 0.03;
'2022': 0.05; 'mar': 0.07; 'subject:when': 0.07; 'sun,': 0.07;
'cc:addr:python-list': 0.09; 'general,': 0.09; 'url:github': 0.14;
'url-ip:140/8': 0.15; 'api.': 0.16; 'borrows': 0.16;
'cc:name:python list': 0.16; 'from:name:marco sulla': 0.16;
'hand,': 0.16; 'inada': 0.16; 'naoki': 0.16; 'slow': 0.16;
'url:cpython': 0.16; 'wrote:': 0.16; 'uses': 0.19;
'cc:addr:python.org': 0.20; 'returns': 0.22; 'skip:_ 10': 0.22;
'cc:2**0': 0.25; 'again,': 0.26; 'takes': 0.31; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'path': 0.33; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'change': 0.36; 'received:209.85':
0.37; 'received:209': 0.39; 'received:209.85.208': 0.39;
'reference': 0.60; 'clear': 0.64; 'during': 0.69; 'strong': 0.69;
'reference.': 0.81; 'points': 0.84; 'subject:before': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=5zP1TldyFuAqaqYUibgimF4NLNygQFsLkMu613ShJVQ=;
b=cY/5xxcZtUiy4KYDs2FxMxX47LicnBm2MBe+ZQbLOdZhkpY4Obx/CzJEwcpdEZ6/UT
NHNfmsnT+4SvAz3M+BBU1F5FJ1v6HpWmQXHaGuk1th9sd5Uwn09G6pb243DtJ3FP0h7D
tcgcs6e0AT9PpOJMvv/dzZxkVuMRE5XZ5urB93/Wp1igqtkgCCbvkKfyJBme9vbOTbsP
3WcP3QcV41XcAu/1SaRw9GSzeylBQqVvl1QqqPiEJ4pad53g6zchcYNdbDvUeOV6tQ0r
YFcVvt19dsgfkz0w+YJBTs3mQzMb328f4kC1rcB6CcWuObQ7dJ3CbrNBVb1uLYSM5L+6
BN1A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=5zP1TldyFuAqaqYUibgimF4NLNygQFsLkMu613ShJVQ=;
b=FjCzQwPpnSlStY2Kf1uwei4R9stmGknMLb/gbtPTQGPlG5fVZlrBJW6ZB5lLfI+R6e
HcStzvtHjJztOFo8ty369gLyhPqn+rk+juXu/nlB8yVD1F5mCmsMWpmfLus+myxpqDi3
x7uKvLMoLBdYRHsZ2VtMmmWOu4Ct0Qke8hBmvYuwITF1OIIEaK8F3TqawAOfzjvZaMo6
63bWvA0Zg5gVMS2FtQi5sR/ETufrB7LHnyB4PrSj9g4ELHGxmHpMkHnLdBqTspLXHqP9
R0GfOnkQjXH766gKUJSxGuDSioAserV46UOtk/KSHILHlOD2hPDuAlIEkYokpIkKpOL4
0yiQ==
X-Gm-Message-State: AOAM531xdehmxB5ygK/iRLSYnAa83yUcluq20DChJvE2SKqd4PqLtTu3
NrDoCDc1hsIpq8d5qVWwkz8YylzIx+2cHR8cdjn7J2EG
X-Google-Smtp-Source: ABdhPJzaNNS7V/Tgn+QAyHav5a5WiYpn8fKxtZE4kd68M4/J2zgChp+dvUDiq7kb4TruuDIM0ycSa2Ps/kBrbDqA4Dw=
X-Received: by 2002:a2e:87d3:0:b0:244:c1ab:91ae with SMTP id
v19-20020a2e87d3000000b00244c1ab91aemr4851208ljj.277.1646582890135; Sun, 06
Mar 2022 08:08:10 -0800 (PST)
In-Reply-To: <CAEfz+TwbRyfhNqjnd4MJgFjk8kK3_q2otNxEoah9eytu=C49yg@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CABbU2U-uByMD0nNH_2TyZZdqGzWiQ5k7fmb-NwettzDx=ouM=w@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8d9scJo8pMaynoW25jmT-ipJc9DMfbEy2ccmEsr1GK7w@mail.gmail.com>
<CAEfz+TwbRyfhNqjnd4MJgFjk8kK3_q2otNxEoah9eytu=C49yg@mail.gmail.com>
 by: Marco Sulla - Sun, 6 Mar 2022 16:07 UTC

On Sun, 6 Mar 2022 at 03:20, Inada Naoki <songofacandy@gmail.com> wrote:
> In general, when reference is borrowed from a caller, the reference is
> available during the API.
> But merge_dict borrows reference of key/value from other dict, not caller.
> [...]
> Again, insertdict takes the reference. So _PyDict_FromKeys() **does**
> INCREF before calling insertdict, when key/value is borrowed
> reference.
> https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2287-L2290
> https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2309-L2311
>
> On the other hand, slow path uses PyIter_Next() which returns strong
> reference. So no need to INCREF it.

Thank you Inada, these points make me things clear now.
(PS: dictobject will change a lot in 3.11... sigh :D)


devel / comp.lang.python / Re: Cpython: when to incref before insertdict

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor