Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

And Bruce is effectively building BruceIX -- Alan Cox


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.173.1650484187.20749.python-list@python.org>

  copy mid

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

  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 05:49:33 +1000
Lines: 20
Message-ID: <mailman.173.1650484187.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>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de NuEVrxKLwFjG/tP2Ddb2iwA7KCT0gbz0YkZ3+oZr4rHg==
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=GDHg3/Qc;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'subject:Why': 0.07; 'underlying': 0.07; 'subject:list': 0.11;
'problem.': 0.15; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'hash': 0.16; 'key,': 0.16;
'wrote:': 0.16; 'values': 0.17; 'thu,': 0.19; 'to:addr:python-
list': 0.20; 'skip:_ 10': 0.22; "i'd": 0.24; '>>>': 0.28;
'message-id:@mail.gmail.com': 0.32; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; "it's":
0.37; 'received:209.85': 0.37; 'class': 0.37; 'received:209':
0.39; 'use': 0.39; 'define': 0.40; 'happen': 0.40; 'otherwise,':
0.40; 'try': 0.40; 'skip:h 10': 0.61; 'above': 0.62; 'here': 0.62;
'top': 0.65; 'change.': 0.69; 'skip:f 30': 0.71; 'inclined': 0.84;
'tables': 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;
bh=r0TCJOvFffF8x56KfPv9OgB55bxKZkl6wcf1SVtpng8=;
b=GDHg3/QcI0VPDS02dcSkDwWT15kTP5r+lxHA50ZIWN6/w56p4q61DUMYqvCUyMe4Y1
8cI2BdH7W+mt+QgoSiB4z3ufli5Sp4xajknB41EWT0Rl6ku3LT7MZw4MMYXK5i7uBheL
Ite5Tzqjpgwh95OUhyC7YpqJ5nNWs/vnCJzo9K3h8LQ6U8GzjAwsSbXan6YheSTKf0CY
kzRdAenW1G+cPrABHHGGllrDpuQC0LspvZI1IQONh5QvhzszS8BjNQGv8BVjPlYyTlfQ
sZcccxPL4jumWlhyxADOzPTmvPaCK05vWLDQmLWN4Zg52IeRgRZ1TDvElph+7nXYWmCK
FjEg==
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;
bh=r0TCJOvFffF8x56KfPv9OgB55bxKZkl6wcf1SVtpng8=;
b=KVF5U7dG1pQD4+xLZZjyvY8I/8iEkGp0iJ4ifqert0KsyuO6bGCdUXuoRqsWq4bfx4
OPNcj1xi+WHpoTAQ0URTjlDjxMl/zPaDlE3mt+roDsJgATCp1SbGwsnKXtNmcWNqNMTx
GIkjno1avTEb6q37Mb0tbWRQR9i+RvP5ufHagqgr8Gjj02fP8yOEffp47QJgf01P0ieP
FkMMs6ug2ELAc262oetPeF+Rdk8TFD34q5aE0iJGzd9paiVCRWqOJhtFn201GTIhGMsf
5pvUaKKI0oxf+BNpDa4Ek2v2nslmG1qLkezQn1EcSpqJXJZ6b6Mkv0m1SPePYS9lhVXN
i1+w==
X-Gm-Message-State: AOAM5307wBRTMW7F3fROl8myNU+neVTkUXNQs3OMsyCnnR69TGqglE77
Vtt7ZPAOoXO44uyIAHzF+fYGjtcihdopeqbgUyrl/dSC
X-Google-Smtp-Source: ABdhPJwFZFBrrHGS33hMDN6nRQJo06MTtIZmnhedelS9u3ot5FRsQvAqyp6AoT66TkkZJvcCFsMTLPSc+votCdgV6z0=
X-Received: by 2002:a7b:c201:0:b0:38f:f7f5:f6db with SMTP id
x1-20020a7bc201000000b0038ff7f5f6dbmr5150959wmi.191.1650484184725; Wed, 20
Apr 2022 12:49:44 -0700 (PDT)
In-Reply-To: <CAD+b3HiODpHznuK3a_OpH_cn-Dw2dS6mZ6=fzfsO3U-35===tw@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: <CAPTjJmqQC30Z_3qErkDbyEcTv843nuWN5AJH6tkXb+7V85z3Dg@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>
 by: Chris Angelico - Wed, 20 Apr 2022 19:49 UTC

On Thu, 21 Apr 2022 at 05:30, Sam Ezeh <sam.z.ezeh@gmail.com> wrote:
>
> Repeating the above points, here is an example of what would happen if
> you tried. Dictionaries require their keys to be immutable as
> under-the-hood they use hash tables and they'd fail when the
> underlying values are allowed to change.
>
> ```
> >>> class HashableList(list):
> ... def __hash__(self):
> ... return functools.reduce(operator.xor, [key * value for
> key, value in enumerate(self)], 5)

Quickie: I'd be inclined to define hash on top of a tuple's hash,
rather than try to design my own and hope that it's suitable. "return
hash(tuple(self))" is a good demonstration of the parallel.

Otherwise, good demonstration of the problem.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor