Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
"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)) ---------- nosy: +steven.daprano resolution: -> rejected stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39178> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com