Message310907
What should happen for:
def f():
if random.random() < 0.5:
a = 1
b = 2
else:
b = 1
a = 2
return locals()
? Right now co_varnames preserves the order that names were encountered when compiling, so it'd be easy to make 'a' come before 'b' in locals(), so the above function returns either {'a': 1, 'b': 2} or {'a': 2, 'b': 1}.
If we want to preserve the illusion that local variables are entries in the locals() dict, though, then the dict ought to be either {'a': 1, 'b': 2}, {'b': 1, 'a': 2}. Making this happen would require extra machinery for an extreme edge case so I'm guessing it's not worth it though. |
|
Date |
User |
Action |
Args |
2018-01-28 03:38:58 | njs | set | recipients:
+ njs, gvanrossum |
2018-01-28 03:38:58 | njs | set | messageid: <1517110738.44.0.467229070634.issue32690@psf.upfronthosting.co.za> |
2018-01-28 03:38:58 | njs | link | issue32690 messages |
2018-01-28 03:38:57 | njs | create | |
|