Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"If value corrupts then absolute value corrupts absolutely."


devel / comp.lang.python / Re: Problem slicing a list with the C API

SubjectAuthor
o Re: Problem slicing a list with the C APIChris Angelico

1
Re: Problem slicing a list with the C API

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Problem slicing a list with the C API
Date: Sun, 13 Mar 2022 10:50:26 +1100
Lines: 33
Message-ID: <mailman.291.1647129039.2329.python-list@python.org>
References: <My-05ih--3-2@tutanota.com>
<CAPTjJmrXVvdm5D-AKT_sj+2Mf2CxPUzmcbWTnQv6v9xeCzy+qQ@mail.gmail.com>
<My-77V7--3-2@tutanota.com>
<CAPTjJmrpq5nTAKAmRG7yt7tiHxruS8KJ9a1U35VeWvKEyvZ+LQ@mail.gmail.com>
<My-T6up--3-2@tutanota.com>
<CAPTjJmqunWCuHY3sqVffW2AmhZZZrGZuM6tuLTv22S51DaaUoA@mail.gmail.com>
<My-VYHx--3-2@tutanota.com>
<CAPTjJmqv80EWxDv+q3L6QYoP_z4-2jGO0qkwc9sYA_6-x7oKaQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de IZYfVA1iHEZh4BFAdEz+0wEw9CGQ/pRozwnxLw3jxauw==
Return-Path: <rosuav@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=Le6c26te;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.033
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; '(which': 0.04; '2022':
0.05; 'mar': 0.07; 'subject:API': 0.07; 'sun,': 0.07;
'fundamental': 0.09; 'objects,': 0.09; 'sometimes,': 0.09;
'subject:list': 0.11; 'answer.': 0.16; 'append': 0.16; 'chrisa':
0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'received:209.85.221.42': 0.16; 'received:mail-
wr1-f42.google.com': 0.16; 'tuples': 0.16; 'wrote:': 0.16;
'python': 0.16; 'uses': 0.19; 'to:addr:python-list': 0.20;
'language': 0.21; 'code': 0.23; 'goal': 0.23; "isn't": 0.27;
'wrong': 0.28; 'question': 0.32; 'guess': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33; "i'll": 0.33;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'trying': 0.35; 'from:addr:gmail.com': 0.35; 'posts': 0.36;
'people': 0.36; 'necessarily': 0.37; 'using': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'thanks': 0.38; 'received:209': 0.39;
'overflow:': 0.40; 'method': 0.61; 'email': 0.63; 'url-
ip:104.26/16': 0.64; 'extend': 0.64; 'your': 0.64; 'now,': 0.67;
'url:net': 0.68; 'solutions': 0.70; 'depending': 0.70; 'front':
0.70; 'them,': 0.70; 'handles': 0.76; 'implemented': 0.76;
'fortunately,': 0.84; 'inconvenient': 0.84; 'incorrect': 0.84;
'strings': 0.84; 'url-ip:172.67.73/24': 0.84; 'differently': 0.91;
'url-ip:104.26.8/24': 0.93; 'url-ip:104.26.9/24': 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
:content-transfer-encoding;
bh=eO5qH0fVQ3AJEnxZqRY1XH6AdFqqcWrBFIU+XQw4gZs=;
b=Le6c26te366zp2DWD60+PMMcq5oUBuXLF3LS1NGLqyO3zkdSYZGa0Gy9pXTwAUfDD5
oCZ2sb0sn1aQE1iU8Ar32SW7xK2AGQEO96LRIMlS+ow1XoQI/dBAmc6HsOKpiWRhgv/f
kldwvK9OwPTlNnxf/v9pG2wefKfVYujMhjzYYDTXCRR02rQeOMaabVTZ5D1cxLt6A/6p
umeb0lmWciCnI5AzUJ5aQhp2JW8MAudHT1kuNlszByRoR4ZV00lUQvoX1CqGLt4l2c2D
bdljiIGEiIOfokszkgDxQYMOmUMRWKKJcrs0S3wXsEEYQAoWEiOtBDfgON7fePqW6tG8
dnPQ==
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:content-transfer-encoding;
bh=eO5qH0fVQ3AJEnxZqRY1XH6AdFqqcWrBFIU+XQw4gZs=;
b=iPgoKmOBarq+ywUEEpmt2tZ6m6js7NPe4gZoxb3scxfSDWWJqgwY27PW99Hc2jOBw5
5XMclqd5qp+Rg4aM8Lf5ytzmY2pjAuCygceYiNuOF3hMujJYOaTC8WUCvPZ2gGUG4aV9
SC0msUecMkTd3BMe2a3BvnAoQaWBjjlANu+9uaHrZe4525mR4/ewaQQDCFQHKP3oL3I6
ZnOH1JBjySU6Z7bZf4bEYhjHj967yCsYwf4oACbV6SUHueupnOcnGKzqrZv3C02LYu74
slpMdvFan/R54qZ/G76m7m2s8RdGcBgCwLWA/9gR5a6QiKjnAoiBVqkZE+DtVn7JJ1Kq
IUkg==
X-Gm-Message-State: AOAM531SYTSN+AtLPiXFrAtaCUQqg+5xDuKqILJfDo9+RisrAqCloDWh
ZcTTUaOHjriHJUSYd4NoFssniQhCHdIiiFFzWKoK41D7v28=
X-Google-Smtp-Source: ABdhPJxTSbsEjHkRbK2qcORJfBm6NZu2lqHtfNpC4oZg3M96YuIGHHcwhzwnJ2jo1X78GOxlTQUq/MCYlHHB6HwrNfM=
X-Received: by 2002:adf:f801:0:b0:1f0:7675:f5e6 with SMTP id
s1-20020adff801000000b001f07675f5e6mr11468153wrp.564.1647129037701; Sat, 12
Mar 2022 15:50:37 -0800 (PST)
In-Reply-To: <My-VYHx--3-2@tutanota.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: <CAPTjJmqv80EWxDv+q3L6QYoP_z4-2jGO0qkwc9sYA_6-x7oKaQ@mail.gmail.com>
X-Mailman-Original-References: <My-05ih--3-2@tutanota.com>
<CAPTjJmrXVvdm5D-AKT_sj+2Mf2CxPUzmcbWTnQv6v9xeCzy+qQ@mail.gmail.com>
<My-77V7--3-2@tutanota.com>
<CAPTjJmrpq5nTAKAmRG7yt7tiHxruS8KJ9a1U35VeWvKEyvZ+LQ@mail.gmail.com>
<My-T6up--3-2@tutanota.com>
<CAPTjJmqunWCuHY3sqVffW2AmhZZZrGZuM6tuLTv22S51DaaUoA@mail.gmail.com>
<My-VYHx--3-2@tutanota.com>
 by: Chris Angelico - Sat, 12 Mar 2022 23:50 UTC

On Sun, 13 Mar 2022 at 10:41, Jen Kris <jenkris@tutanota.com> wrote:
>
>
> Thanks for PySequence_InPlaceConcat, so when I need to extend I'll know what to use. But my previous email was based on incorrect information from several SO posts that claimed only the extend method will work to add tuples to a list. I found that's wrong -- even my own Python code uses the append method. But my PyList_Append is not doing the job so that's where I'm looking now.
>

Ah. I guess that's one of the fundamental vulnerabilities of Stack
Overflow: people answer the question in front of them, which isn't
necessarily the question that YOU are trying to answer. Sometimes, the
solutions can be misleading, because your goal is actually different.

Fortunately, tuples in Python are objects, like every other value.
It's extremely convenient - to word that another way, it's extremely
INconvenient to work with a language where that isn't the case, and
you need to work differently depending on whether you're using
integers or strings. This is how you work with a trie (actually an
artifact name now, as it's implemented with a hashtable) in SourceMod
- this is the equivalent of dictionary subscript assignment:

https://sm.alliedmods.net/new-api/adt_trie/SetTrieValue
- works for integers, floats, and handles (which are integers)

https://sm.alliedmods.net/new-api/adt_trie/SetTrieString
- works for strings

Yup, it's annoying :)

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor