Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

No user-servicable parts inside. Refer to qualified service personnel.


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

SubjectAuthor
o Re: Why no list as dict key?Dan Stromberg

1
Re: Why no list as dict key?

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: drsali...@gmail.com (Dan Stromberg)
Newsgroups: comp.lang.python
Subject: Re: Why no list as dict key?
Date: Wed, 20 Apr 2022 20:28:46 -0700
Lines: 23
Message-ID: <mailman.179.1650511741.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>
<CAGGBd_rE_eHwy-zsdQuHvoCTHusrnsL==+c_ja08oTsea3TkZw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de H3o1ihV3VPij6F8PGFfHmAFaOrw7QzJkocxVfT/evAUQ==
Return-Path: <drsalists@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=DWMCw8sk;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '2022': 0.05;
'subject:Why': 0.07; 'cc:addr:python-list': 0.09; 'list.\xc2\xa0':
0.09; 'though.': 0.09; 'values.': 0.09; 'subject:list': 0.11;
'assuming': 0.16; 'cc:name:python': 0.16; 'dict': 0.16;
'duplicates': 0.16; 'eg:': 0.16; 'from:addr:drsalists': 0.16;
'from:name:dan stromberg': 0.16; 'hash': 0.16; 'janhangeer': 0.16;
'want,': 0.16; 'wrote:': 0.16; 'problem': 0.16;
'cc:addr:python.org': 0.20; 'issue': 0.21; 'languages': 0.22;
'maybe': 0.22; 'cc:2**1': 0.23; 'object': 0.26; 'so.': 0.26;
'bit': 0.27; 'modify': 0.31; 'message-id:@mail.gmail.com': 0.32;
'but': 0.32; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'using':
0.37; 'received:209.85': 0.37; 'could': 0.38; 'received:209':
0.39; 'two': 0.39; 'received:209.85.222': 0.39; 'wed,': 0.39;
'case.': 0.40; 'want': 0.40; 'should': 0.40; 'look': 0.65; '20,':
0.67; 'drop': 0.69; 'functional': 0.69; 'themselves.': 0.69;
'speed': 0.71; 'tables': 0.84; 'association': 0.86
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=9Li6Fd2WnxDeXP2ZOsgWZxjF0Zmz7veYVSyLml3obMg=;
b=DWMCw8skAQclvzUK0M/RLMsB5yUXhtidCJdai2XptKQI3NlHtYTT2nfHAg6Dkv93rj
tK00HlmDpQM553RaZmrl4AgYo6DiyNrm1RDKj+K37v3zADXKt4TBFxYLvHTiCuAj29xE
aCYVMWCqOmXQ3zw1aIAijjCKhACQCNzt9IQPGJEm2Cb0CQOkS2jtFhkPhlj+Hucl128q
/AWPZ0bSj48fTA+fKt5m0GNvhyGVK0Re/bHYBpf19YJA5Zy8CrFKBQx6XcipvvZDTzUB
BXoouah+mdB8m9PC9nIU2K6+xT6mOWFtnQhFQ+Dmd7jS7MZPpdUZDZPuC6Yh0WYasiyB
jdFQ==
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=9Li6Fd2WnxDeXP2ZOsgWZxjF0Zmz7veYVSyLml3obMg=;
b=c06tM0SYCRjtzs4UhP5w3J4Svw3gJOPuwKpU/xfd7lydTuXAXB+EMbNK3JoL26FFfi
2wpno0Zc++WXjKyZyd99kzv8/enfP6Eg/BL8ADt9deNIWhpvFVs2CZtqPPC/N7we+Lsi
2+iOL+cTFwxNAayvgo8Gp2obGuShMsytsj5UMTTKXzmeJBxtUgNs+qShcf6K5Sv3QeUq
wvHu25VQXZyEXJaQfEVQbOwfRQp4kjAaB/gSFY2qWJNGBVX29aE06W5pOhTxsDz03NgZ
Pe0tYR1qCwpn2odXIdRryVMnuS4pMF09XsC0PXfAVFz2mmNufTUfm+tag/OYAJ84V8F+
pg6Q==
X-Gm-Message-State: AOAM5307zQcE5ikiquIqb/tVuiF3bHS4i9onO8tZfkid2OirpEEOpDd8
EL9JapgDTilt8qP9idHMekH2z1eZF04A93exgFc=
X-Google-Smtp-Source: ABdhPJweA96zXQA9Iq9kvOgJaKCLm6wEHcIhgHlk7f3Jg+fMfgvSrpKVvZ7N7IkL5tUY/hEB33ylB9aD4thISG8ya7Q=
X-Received: by 2002:ab0:6f8f:0:b0:35d:5045:46c4 with SMTP id
f15-20020ab06f8f000000b0035d504546c4mr6360323uav.116.1650511737966; Wed, 20
Apr 2022 20:28:57 -0700 (PDT)
In-Reply-To: <CADrxXX=z_rtsBs29SDzPJTqgcHcUaKFcNUu4AXcCdoi0X+2-fA@mail.gmail.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CAGGBd_rE_eHwy-zsdQuHvoCTHusrnsL==+c_ja08oTsea3TkZw@mail.gmail.com>
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>
 by: Dan Stromberg - Thu, 21 Apr 2022 03:28 UTC

On Wed, Apr 20, 2022 at 7:23 PM Abdur-Rahmaan Janhangeer <
arj.python@gmail.com> wrote:

> Maybe hashes should point to an object rather than being the hash of an
> object themselves.
> Maybe the speed drop is not worth it.
>

If you need mutable keys, you /might/ create a dict-like-object using what
functional languages call an association list. But these have O(n)
lookups, not O(1) like a dict (AKA hash table). And even then, if you have
keys a and b, a != b, and you modify b to look just like a, you could get a
bit of a mess from the two equal keys mapping to two different values.

It is possible to have a dict that allows duplicates though. Usually
that's not what you want, but sometimes it is, EG:
https://stromberg.dnsalias.org/~strombrg/dupdict_mod/

Trees have much the same issue as a dict (hash table) in this case. These
are O(logn) or so.

The problem is hash tables and trees don't want keys changing "out from
under them". It causes things they're assuming are invariant, to vary.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor