Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Truth has always been found to promote the best interests of mankind... -- Percy Bysshe Shelley


devel / comp.lang.python / Re: Why no list as dict key?

SubjectAuthor
o Re: Why no list as dict key?Chris Angelico

1
Re: Why no list as dict key?

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

  copy mid

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

  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: Why no list as dict key?
Date: Thu, 21 Apr 2022 06:43:00 +1000
Lines: 19
Message-ID: <mailman.175.1650487393.20749.python-list@python.org>
References: <CADrxXXmWEjmQmR0-mP7tugrEJ1YhqBCt_X-57fumqft4=rNPYw@mail.gmail.com>
<CAD+b3HiODpHznuK3a_OpH_cn-Dw2dS6mZ6=fzfsO3U-35===tw@mail.gmail.com>
<CAPTjJmqQC30Z_3qErkDbyEcTv843nuWN5AJH6tkXb+7V85z3Dg@mail.gmail.com>
<1278120400.1002892.1650485929612@mail.yahoo.com>
<CAPTjJmriaQ6tcECi5QSo7S-K5Xs+92OEfGe78OJ04488j6COig@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 jdiCKIgh12K7P4YO7YV2KgDazqLtJSgHaDo4BykA7BQQ==
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=Rmw9CQX1;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05;
'subject:Why': 0.07; 'obviously': 0.09; 'situations': 0.09;
'yes.': 0.09; 'subject:list': 0.11; 'avi': 0.16; 'chrisa': 0.16;
'dictionary.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'gross': 0.16; 'item,': 0.16; 'key,': 0.16;
'key.': 0.16; 'situations.': 0.16; 'tuple': 0.16; 'wrote:': 0.16;
'reached': 0.17; "can't": 0.17; 'thu,': 0.19; 'to:addr:python-
list': 0.20; 'list,': 0.24; 'to:name:python-list@python.org':
0.24; 'raise': 0.31; 'deleted': 0.32; 'python-list': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'from:addr:gmail.com':
0.35; 'change': 0.36; 'those': 0.36; 'received:209.85': 0.37;
'received:209': 0.39; 'list': 0.39; 'use': 0.39; 'method': 0.61;
'data,': 0.63; 'your': 0.64; 'items': 0.68; 'converted': 0.84
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=tC5eLFvJwknbI4pZW2myp4VcpAldOOz1Po845kAUIwg=;
b=Rmw9CQX1B7u18tc3dBhyvmUcdugVVBaiCcs60MQVYN6uz+3GDavcI7I/FWNgT7OGx/
w+wCdXMAJlHi6LMZFNQayQ+mW9hzN+IQaUbHaZYiuYpM1yEKrXfDRSaTN8LvayKEzXU6
PA87I4r0pOBCVUUmJ806XU4xP/vKuc0LKgOXVpGqrxRimMWE/79jlWjaGAojxTLVt1z1
8RwWZ1pvnL5Lxgfq832Rvr7Mqew6dDUjwZtu/oXYPoX6gTLmknSefToSYldMMWifcsKz
ni++FOOAQQ+PRGDe/iO9Cb8Sn5I4icnhQ0qlYrNh91XyhSghVPdmsVJv2u8SXxIIOaOr
iDIg==
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=tC5eLFvJwknbI4pZW2myp4VcpAldOOz1Po845kAUIwg=;
b=wENESxEpM3boqUbvjZyONfMJAwJTTklov4fAcVBbklqKCqOy7EkseBmQppDjNhuOsP
WQgXr7RLvxqaj2kfqIaxbp2LlBa5lvv6DgN7lOFiJz7ymt2ndlXk5XNGYaIDqKCB+bld
/KHTVNIpaq7FAyhhtv4Zw/rkbJ4Yz3Erx9GlMta/FSnvc4zRGoC0ZwNf2I2rsT4Ft9mf
Ibvgsl9I61WgnoZvVYBqaiDIiqQlJPIOADTV99wrdTkl2ctNKuQaz99TkDfDjNg63XYw
MwfSdgs9by80hP2MZ/ebZ83bRtCY6Y14pIPXamZ5TPnAtDxGjaawuGdzyIybnTupm1TM
UhOA==
X-Gm-Message-State: AOAM533OaOdSmb2lq3gImIkoWoINya4SyH8mPBWtBxCt+yhelS+OxWMu
DGP3NoPo9qEWF80FB1k07xniQikDvN1wg/NdjVjVV5mM
X-Google-Smtp-Source: ABdhPJw9feRJtU4v57fWDhGtpDvaRFYL60c7lQzaEv+Rtk7UVJ0VTnBoiFdkRJqO6sHysseKRMPj5dXg6teHwYn9XTI=
X-Received: by 2002:a05:6000:188d:b0:20a:a014:7ff6 with SMTP id
a13-20020a056000188d00b0020aa0147ff6mr9864715wri.104.1650487391424; Wed, 20
Apr 2022 13:43:11 -0700 (PDT)
In-Reply-To: <1278120400.1002892.1650485929612@mail.yahoo.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: <CAPTjJmriaQ6tcECi5QSo7S-K5Xs+92OEfGe78OJ04488j6COig@mail.gmail.com>
X-Mailman-Original-References: <CADrxXXmWEjmQmR0-mP7tugrEJ1YhqBCt_X-57fumqft4=rNPYw@mail.gmail.com>
<CAD+b3HiODpHznuK3a_OpH_cn-Dw2dS6mZ6=fzfsO3U-35===tw@mail.gmail.com>
<CAPTjJmqQC30Z_3qErkDbyEcTv843nuWN5AJH6tkXb+7V85z3Dg@mail.gmail.com>
<1278120400.1002892.1650485929612@mail.yahoo.com>
 by: Chris Angelico - Wed, 20 Apr 2022 20:43 UTC

On Thu, 21 Apr 2022 at 06:20, Avi Gross via Python-list
<python-list@python.org> wrote:
>
> This does raise an issue, Chris, if you use the method of making a tuple companion for a list at a specific time just for use as a dictionary key, then later change the list, you can end up with various situations.
>

Yes. And those situations are *exactly* why you can't use a list as a key.

> Obviously the changed list can not only not access the stored item, but if converted again to a tuple, may address a different item. I can see many scenarios with abandoned dictionary items that are never deleted and can only be reached by examining all items in the dictionary.
> So mutability is only one concern. If you actually mutate your data, ...

And if you don't mutate your data, use a tuple.

ChrisA


devel / comp.lang.python / Re: Why no list as dict key?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor