Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

24 Apr, 2024: Testing a new version of the Overboard here. If you have an issue post about it to rocksolid.nodes.help (I know. Everyone on Usenet has issues)


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

SubjectAuthor
o Re: Why no list as dict key?Peter J. Holzer

1
Re: Why no list as dict key?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-pyt...@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: Why no list as dict key?
Date: Mon, 25 Apr 2022 15:54:31 +0200
Lines: 51
Message-ID: <mailman.250.1650894879.20749.python-list@python.org>
References: <CADrxXXmWEjmQmR0-mP7tugrEJ1YhqBCt_X-57fumqft4=rNPYw@mail.gmail.com>
<CAPTjJmovXqzOemVUCSoLQS--7egCj9ZQFA9DOQ9U=mgcFvUnZg@mail.gmail.com>
<CADrxXX=z_rtsBs29SDzPJTqgcHcUaKFcNUu4AXcCdoi0X+2-fA@mail.gmail.com>
<YmDGBT1SDbiUc8a4@scrozzle>
<CADrxXXkQekikNbeBxWpM=yLc6Vk2C5JSFo1AN2Db0fX7uSPNFQ@mail.gmail.com>
<CAPTjJmph9HRduN2Ms74t13ORB+zEYXmfCZLVMz=MStpnYsABxg@mail.gmail.com>
<be8b7956-d34c-3d78-ec2b-d74f293625ef@solute.de>
<20220425135431.tffgmtsugp5z5yj5@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="s5mvekgsi5rz5qfl"
X-Trace: news.uni-berlin.de YNH63+uvtgCGPfdh872XBQWWZqm9mM5adw94NE3idmzg==
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content-
type:multipart/signed': 0.05; 'string': 0.07; 'subject:Why': 0.07;
'content-type:application/pgp-signature': 0.09; 'filename:fname
piece:asc': 0.09; 'filename:fname piece:signature': 0.09;
'filename:fname:signature.asc': 0.09; 'subject:list': 0.11;
'"creative': 0.16; '(even': 0.16; '+0200,': 0.16; '__/': 0.16;
'attributes': 0.16; 'challenge!"': 0.16; 'dict': 0.16; 'dicts':
0.16; 'from:addr:hjp-python': 0.16; 'from:addr:hjp.at': 0.16;
'from:name:peter j. holzer': 0.16; 'hjp@hjp.at': 0.16; 'holzer':
0.16; 'iterable': 0.16; 'reality.': 0.16; 'stross,': 0.16;
'structures:': 0.16; 'subset': 0.16; 'tuples': 0.16; 'units,':
0.16; 'url-ip:212.17.106.137/32': 0.16; 'url-ip:212.17.106/24':
0.16; 'url-ip:212.17/16': 0.16; 'url:hjp': 0.16; '|_|_)': 0.16;
'wrote:': 0.16; 'values': 0.17; 'probably': 0.17; 'to:addr:python-
list': 0.20; 'sense': 0.28; 'objects': 0.32; 'header:In-Reply-
To:1': 0.34; 'complex': 0.35; 'though': 0.37; 'use': 0.39;
'case.': 0.40; 'something': 0.40; 'want': 0.40; 'received:212':
0.62; 'look': 0.65; 'received:userid': 0.66; 'url-ip:212/8': 0.69;
'records': 0.75; 'ask,': 0.84; 'received:at': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <be8b7956-d34c-3d78-ec2b-d74f293625ef@solute.de>
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: <20220425135431.tffgmtsugp5z5yj5@hjp.at>
X-Mailman-Original-References: <CADrxXXmWEjmQmR0-mP7tugrEJ1YhqBCt_X-57fumqft4=rNPYw@mail.gmail.com>
<CAPTjJmovXqzOemVUCSoLQS--7egCj9ZQFA9DOQ9U=mgcFvUnZg@mail.gmail.com>
<CADrxXX=z_rtsBs29SDzPJTqgcHcUaKFcNUu4AXcCdoi0X+2-fA@mail.gmail.com>
<YmDGBT1SDbiUc8a4@scrozzle>
<CADrxXXkQekikNbeBxWpM=yLc6Vk2C5JSFo1AN2Db0fX7uSPNFQ@mail.gmail.com>
<CAPTjJmph9HRduN2Ms74t13ORB+zEYXmfCZLVMz=MStpnYsABxg@mail.gmail.com>
<be8b7956-d34c-3d78-ec2b-d74f293625ef@solute.de>
 by: Peter J. Holzer - Mon, 25 Apr 2022 13:54 UTC
Attachments: signature.asc (application/pgp-signature)

On 2022-04-25 15:13:19 +0200, Lars Liedtke wrote:
> May I stupidly ask, why one would want to use an iterable (even immutable)
> as dict key?

A string is also an immutable iterable, so this is probably even the
most common case.

As for more complex data structures:

* Tuples or immutable dicts are a good fit if want to group records by
subset of their attributes (think "group by" in SQL)

* Objects in general are often though of as units, even if they have
composite values and you might want to look up something by that
value.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor