Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"And remember: Evil will always prevail, because Good is dumb." -- Spaceballs


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

SubjectAuthor
o Re: Non-deterministic set orderingRob Cliffe

1
Re: Non-deterministic set ordering

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

 copy mid

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

 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:40:54 +0100
Lines: 51
Message-ID: <mailman.424.1652672463.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>
<8c947b633c736874f99a09320d0b44c4af10d686.camel@anode.ca>
<6728f650-79b3-8a9a-f001-38a0b54dd65c@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 ykOodSQ8qOayOqgbI6tS+AQ4bTe+5iAVvJyIVopFDCrw==
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=UY3JZn3D;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.041
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'pfxlen:0': 0.03; '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; '>>>': 0.28;
'output': 0.28; 'email addr:python.org&gt;': 0.28; 'header:User-
Agent:1': 0.30; 'program': 0.31; 'question': 0.32; '(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; 'mon,': 0.36; '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; 'it:': 0.69; 'repeatedly': 0.69; 'within': 0.69; 'discover':
0.80; 'paul': 0.81; 'bryan': 0.84; '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=1652672455;
bh=Vr/aG8l8onTokooLGNB/7TBbxvTUkyc143fSZrzf2DM=;
h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To;
b=UY3JZn3DCm/EVUV/GV8G9JwXjR5nyZvNATYeB06pe6n9i0mJ29fvUwcJtfXMISSqlBrHrul7K0j3UwIlvOCkQohypVYyoWTE5XEq0PBr9zOOZ8p++rOE0rgF3ujTqwCRNCEQZILY9KlChUsFoO17Rsk/BAW2wqLlFYryWzovl1K7UcVvbNZ13d0XFttg6I7eW4TO805uz0dmasyDDnIw7HJTLKkdg6+quOEbXYnvpnXyVlNIbS09yQwGV4qgruZE1g6cK7Bd2T+3bR9gqNxIbkFYRq0LgYsCntcTw1wnAzy4WnHVZXC2BaLLTlgsjHSLYFlPvcjGIqoPlehF87ANfQ==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=rob.cliffe@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 613A8DE8237F2E19
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: gggruggvucftvghtrhhoucdtuddrgedvfedrheeggdejiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurheptgfkffggfgfuvfevfhfhjgesrgdtreertdefjeenucfhrhhomheptfhosgcuvehlihhffhgvuceorhhosgdrtghlihhffhgvsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepgfetvdfgueetjedvhfevkeevheevfeejhfeftddviedtffefveevveevvddtudeinecuffhomhgrihhnpehsthgrtghkohhvvghrfhhlohifrdgtohhmpdhgrhgrnhhtjhgvnhhkshdrtghomhenucfkphepvddujedrgeefrddvgedrvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegludelvddrudeikedruddrvddtgegnpdhinhgvthepvddujedrgeefrddvgedrvddpmhgrihhlfhhrohhmpehrohgsrdgtlhhifhhfvgessghtihhnthgvrhhnvghtrdgtohhmpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepphgsrhihrghnsegrnhhouggvrdgtrgdprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrgh
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: <8c947b633c736874f99a09320d0b44c4af10d686.camel@anode.ca>
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: <6728f650-79b3-8a9a-f001-38a0b54dd65c@btinternet.com>
X-Mailman-Original-References: <d93aad1d-8586-b844-d3de-fa9648535244@btinternet.com>
<CAGGBd_p3SqB-GRBW+DdTY6++DmJ2qHfJtQUK1u2Y18CG3nWuEA@mail.gmail.com>
<d26dd6fb-ff48-1269-6e2a-acd69e5fc3f6@btinternet.com>
<8c947b633c736874f99a09320d0b44c4af10d686.camel@anode.ca>
 by: Rob Cliffe - Mon, 16 May 2022 03:40 UTC

Thanks, Paul.  Question answered!
Rob Cliffe

On 16/05/2022 04:36, Paul Bryan wrote:
> This may explain it:
> https://stackoverflow.com/questions/27522626/hash-function-in-python-3-3-returns-different-results-between-sessions
>
> On Mon, 2022-05-16 at 04:20 +0100, Rob Cliffe via Python-list wrote:
>>
>>
>> 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.7
clearnet tor