Message293265
According to the documentation, random.shuffle() should accept a sequence. But it also accepts dicts, in which case it does nothing, expensively:
py> x = dict.fromkeys(range(10**6))
py> random.shuffle(x)
py> str(x)[:55] + "...}"
'{0: None, 1: None, 2: None, 3: None, 4: None, 5: None, ...}'
I'm not sure if it is better to explicitly test for and reject dicts and mappings, or just document that sorting dicts will apparently succeed while doing nothing.
Do we want to support sorting OrderedDicts? That at least makes sense, since they have an order, but again shuffle() seemingly works but actually does nothing.
I lean towards explicitly testing for dicts and raising. |
|
Date |
User |
Action |
Args |
2017-05-09 01:34:22 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger |
2017-05-09 01:34:22 | steven.daprano | set | messageid: <1494293662.45.0.505067861838.issue30311@psf.upfronthosting.co.za> |
2017-05-09 01:34:22 | steven.daprano | link | issue30311 messages |
2017-05-09 01:34:21 | steven.daprano | create | |
|