Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

What this country needs is a good five cent microcomputer.


devel / comp.lang.python / Re: Non-deterministic set ordering

SubjectAuthor
o Re: Non-deterministic set orderingRob Cliffe

1
Re: Non-deterministic set ordering

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rob.cli...@btinternet.com (Rob Cliffe)
Newsgroups: comp.lang.python
Subject: Re: Non-deterministic set ordering
Date: Mon, 16 May 2022 04:20:50 +0100
Lines: 42
Message-ID: <mailman.422.1652671258.20749.python-list@python.org>
References: <d93aad1d-8586-b844-d3de-fa9648535244@btinternet.com>
<CAGGBd_p3SqB-GRBW+DdTY6++DmJ2qHfJtQUK1u2Y18CG3nWuEA@mail.gmail.com>
<d26dd6fb-ff48-1269-6e2a-acd69e5fc3f6@btinternet.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de tYoCxPWeHzU2jYxcNVx3DAm5SPnrSp24Pdr6D0i6xa2A==
Return-Path: <rob.cliffe@btinternet.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=btinternet.com header.i=@btinternet.com header.b=oar/g6S8;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.041
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; '2022': 0.05; 'sun,': 0.07;
'cc:addr:python-list': 0.09; 'dan': 0.09; 'identical': 0.09;
'order,': 0.09; '"real"': 0.16; 'assuming': 0.16;
'cc:name:python': 0.16; 'operations,': 0.16; 'order?': 0.16;
'tasks.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'round': 0.19;
'cc:addr:python.org': 0.20; 'code': 0.23; 'list,': 0.24;
'cc:2**0': 0.25; 'anyone': 0.25; 'seems': 0.26; 'output': 0.28;
'email addr:python.org&gt;': 0.28; 'header:User-Agent:1': 0.30;
'program': 0.31; '(as': 0.32; 'python-list': 0.32; "wouldn't":
0.32; 'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33;
'same': 0.34; 'header:In-Reply-To:1': 0.34; 'running': 0.34;
'subject:skip:d 10': 0.35; 'following': 0.35; 'thanks,': 0.36;
'received:192.168': 0.37; 'developers': 0.39; 'use': 0.39;
'explain': 0.40; 'received:213': 0.40; 'wishes': 0.40;
'something': 0.40; 'should': 0.40; 'best': 0.61; 'come': 0.62;
'your': 0.64; 'produce': 0.65; 'operations': 0.68; 'repeatedly':
0.69; 'within': 0.69; 'discover': 0.80; 'email name:&lt;python-
list': 0.84; 'ordering': 0.84; 'rob': 0.84; 'subject:Non': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'shocked': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1652671250;
bh=2IBGmxUl88qjFXJhzpO4Tdbu1XFuapmf+//gSVHhPGM=;
h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To;
b=oar/g6S8MPux5+KklSoX/yUZ3A3rh4VUmFv+f2+QHNR3EOiW2OrMbr358KBqNEF1HtLUiO7TeroYtROSKHS9ItKxaZy3omSPyE8ZxPI0r9IWenbEIcFxz8s+xAwOCIxqrUEnDxkcJ5c4cJ/vzs5GASCdN1jGMSkLFleViz1/Nw6EnEIKxga9T9SfabUG9JdN6BLgc4mTSZHCoywLFGA41D7QX1iN0XSsybyFTeIj/Hvkr3XnChfIU8ScDPLmMvOFrfmXgmQ5pgY6Id6DUScaEWZHdWW4QafVdU8wLQCR3zsfbRud60JRvrzl4Mx/LAMVye2AmVxyElL1E36aWz6pmA==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 613943C624361555
X-Originating-IP: [217.43.24.2]
X-OWM-Source-IP: 217.43.24.2 (GB)
X-OWM-Env-Sender: rob.cliffe@btinternet.com
X-VadeSecure-score: verdict=clean score=0/300, class=clean
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvfedrheeggdejvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpegtkfffgggfuffvvehfhfgjsegrtderredtfeejnecuhfhrohhmpeftohgsucevlhhifhhfvgcuoehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmqeenucggtffrrghtthgvrhhnpeeiheeikeekfeejtdeigfekjedutdeltdfgleeuvdejtdejudfhteehgfduffdtffenucffohhmrghinhepghhrrghnthhjvghnkhhsrdgtohhmnecukfhppedvudejrdegfedrvdegrddvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurddvtdegngdpihhnvghtpedvudejrdegfedrvdegrddvpdhmrghilhhfrhhomheprhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegurhhsrghlihhsthhssehgmhgrihhlrdgtohhmpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-SNCR-hdrdom: btinternet.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Content-Language: en-GB
In-Reply-To: <CAGGBd_p3SqB-GRBW+DdTY6++DmJ2qHfJtQUK1u2Y18CG3nWuEA@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: <d26dd6fb-ff48-1269-6e2a-acd69e5fc3f6@btinternet.com>
X-Mailman-Original-References: <d93aad1d-8586-b844-d3de-fa9648535244@btinternet.com>
<CAGGBd_p3SqB-GRBW+DdTY6++DmJ2qHfJtQUK1u2Y18CG3nWuEA@mail.gmail.com>
 by: Rob Cliffe - Mon, 16 May 2022 03:20 UTC

On 16/05/2022 04:13, Dan Stromberg wrote:
>
> On Sun, May 15, 2022 at 8:01 PM Rob Cliffe via Python-list
> <python-list@python.org> wrote:
>
> I was shocked to discover that when repeatedly running the following
> program (condensed from a "real" program) under Python 3.8.3
>
> for p in { ('x','y'), ('y','x') }:
>      print(p)
>
> the output was sometimes
>
> ('y', 'x')
> ('x', 'y')
>
> and sometimes
>
> ('x', 'y')
> ('y', 'x')
>
> Can anyone explain why running identical code should result in
> traversing a set in a different order?
>
>
> Sets are defined as unordered so that they can be hashed internally to
> give O(1) operations for many tasks.
>
> It wouldn't be unreasonable for sets to use a fixed-by-arbitrary
> ordering for a given group of set operations, but being unpredictable
> deters developers from mistakenly assuming they are ordered.
>
> If you need order, you should use a tuple, list, or something like
> https://grantjenks.com/docs/sortedcontainers/sortedset.html
Thanks, I can work round this behaviour.
But I'm curious: where does the variability come from?  Is it deliberate
(as your answer seems to imply)?  AFAIK the same code within the *same
run* of a program does produce identical results.
Best wishes
Rob Cliffe

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor