New submission from Dan Gheorghe Haiduc <danuthai...@gmail.com>:

Now that dicts are ordered[1], would it by any chance make sense to also order 
sets?

A use case that I ran into is trying to reproducibly get a random.choice from a 
set (after calling random.seed). 

At first I did not need reproducibility, and I just called 
random.choice(list(my_set)). 

Later when I did need it, it was difficult to find out what was wrong. Then I 
realized that sets are unordered, and that order is not dependent on 
random.seed.

It seems there are also some other confused newbies out there.[2][3]

Thank you for the powerful language that is Python!

[1] https://www.python.org/dev/peps/pep-0468
[2] https://stackoverflow.com/q/11929701/235463
[3] https://stackoverflow.com/q/36317520/235463

----------
components: Interpreter Core
messages: 381088
nosy: danuker
priority: normal
severity: normal
status: open
title: Make set ordered
type: enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42368>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to