Message357079
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}' |
|
Date |
User |
Action |
Args |
2019-11-20 15:36:33 | Ylem | set | recipients:
+ Ylem, steven.daprano, josh.r |
2019-11-20 15:36:33 | Ylem | set | messageid: <1574264193.29.0.0751131960419.issue38853@roundup.psfhosted.org> |
2019-11-20 15:36:33 | Ylem | link | issue38853 messages |
2019-11-20 15:36:32 | Ylem | create | |
|