Cat Chenal <[email protected]> added the comment:
Thank you for pointing out my lack of clarity: I apologize.
I probably should not have split this issue in two (issue38855).
My confusion stems from the fact that I expected the unpacking of a set to
return the same output as that obtained from the unpacking of a list.
>From my testing, I gather that the unpacking of a set is performed via its
>repr, which uses "some ordering".
In closing, I want to note two points:
1. repr is apparently platform-dependent (here: Python 3.6.7 [MSC v.1900 64 bit
(AMD64)]):
The code given by steven.daprano run in a jupyter lab cell or in VS Code yields
a different output:
>>> repr({4, 5, 2**31+1, 2, 2**31+2, 3, 2**31, 0})
'{2147483648, 2147483649, 2, 2147483650, 4, 5, 3, 0}'
2. Testing reviewer's assertion: "The specific order you see will depend on the
specific values in the set, as well as the order that they were inserted,
deleted, and/or re-inserted in some arbitrary way."
This counter example, where element 0 is moved to the second position, shows
that there is not such order dependence:
>>> repr({4, 0, 5, 2**31+1, 2, 2**31+2, 3, 2**31})
'{0, 2147483649, 2, 2147483650, 4, 5, 3, 2147483648}'
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38853>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com