This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients rhettinger, steven.daprano
Date 2017-05-09.01:34:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494293662.45.0.505067861838.issue30311@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-05-09 01:34:22steven.dapranosetrecipients: + steven.daprano, rhettinger
2017-05-09 01:34:22steven.dapranosetmessageid: <1494293662.45.0.505067861838.issue30311@psf.upfronthosting.co.za>
2017-05-09 01:34:22steven.dapranolinkissue30311 messages
2017-05-09 01:34:21steven.dapranocreate