Nick Coghlan <[email protected]> added the comment:
The current discrepancy is odd when you compare it to the equivalent generator
expression:
{k:v for k, v in iterable}
dict(((k, v) for k, v in iterable))
It would never have occurred to me to expect the evaluation order to match a
fully unrolled loop with a nested "d[k] = v" assignment, because the dict
constructor doesn't work that way - it accepts an iterable of 2-tuples.
PEP 274 also specifies the iterable-of-2-tuples interpretation (using a list
comprehension as its baseline rather than a generator expression):
https://www.python.org/dev/peps/pep-0274/#semantics
----------
nosy: +ncoghlan
versions: +Python 3.8 -Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue29652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com