When convert two sets with the same elements to lists, are the lists always going to be the same?

Terry Reedy tjreedy at udel.edu
Fri May 4 13:43:12 EDT 2012


On 5/4/2012 8:00 AM, Peng Yu wrote:
> On Fri, May 4, 2012 at 6:21 AM, Chris Angelico<rosuav at gmail.com>  wrote:
>> On Fri, May 4, 2012 at 8:14 PM, Peng Yu<pengyu.ut at gmail.com>  wrote:
>>> Thanks. This is what I'm looking for. I think that this should be
>>> added to the python document as a manifestation (but nonnormalized) of
>>> what "A set object is an unordered collection of distinct hashable
>>> objects" means.
>>
>> There are other things that can prove it to be unordered, too; the
>> exact pattern and order of additions and deletions can affect the
>> iteration order. The only thing you can be sure of is that you can't
>> be sure of it.
>
> I agree. My point was just to suggest adding more explanations on the
> details in the manual.

I am not sure how much clearer we can be in the language manual. The 
word 'unordered' means just that. If one imposes an arbitrary linear 
order on an unordered collection, it is arbitrary. It is frustrating 
that people do not want to believe that, and even write tests depending 
on today's arbitrary serialization order being deterministic 
indefinitely. There is a section about this in the doctest doc, but 
people do it anyway. I will think about a sentence to add.

-- 
Terry Jan Reedy




More information about the Python-list mailing list