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 DeepSpace, methane, rhettinger, serhiy.storchaka, steven.daprano
Date 2020-01-01.15:44:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577893470.17.0.568137170886.issue39178@roundup.psfhosted.org>
In-reply-to
Content
"should dict preemptively make sure it doesn't accept a sequence of sets"

No. The person on StackOverflow made a mistake in their code: they used an unordered data structure (set) instead of an ordered data structure (tuple):

    dict({i,j} for i,j in enumerate(lst))

It is a waste of time to slow down the dict constructor to check for something so unusual as this. Everyone will pay the cost of the checks and virtually no-one will get any benefit.

I'm closing this as "rejected", but if anyone disagrees they can reopen it.

By the way, the best way to initialise a dictionary in this situation is to avoid the unnecessary generator expression and just go straight to enumerate:

    dict(enumerate(lst))
History
Date User Action Args
2020-01-01 15:44:30steven.dapranosetrecipients: + steven.daprano, rhettinger, methane, serhiy.storchaka, DeepSpace
2020-01-01 15:44:30steven.dapranosetmessageid: <1577893470.17.0.568137170886.issue39178@roundup.psfhosted.org>
2020-01-01 15:44:30steven.dapranolinkissue39178 messages
2020-01-01 15:44:29steven.dapranocreate