Message270842
Consider the following code:
$ cat x.py
from collections import OrderedDict
class X:
def items(self):
print('items')
return []
def keys(self):
print('keys')
return []
print(dict(X()))
print(OrderedDict(X()))
When I run it under python 3.4, I get
$ python3.4 x.py
keys
{}
keys
OrderedDict()
but under python 3.5, I get
$ python3.5 x.py
keys
{}
items
OrderedDict()
Under 3.4 both dict and OrderedDict constructors call the keys() method of the underlying object (and then call __getitem__ repeatedly if keys() returns a non-empty list), but in 3.5 OrderedDict behavior changed and it calls the values() method instead. |
|
Date |
User |
Action |
Args |
2016-07-19 21:01:30 | belopolsky | set | recipients:
+ belopolsky |
2016-07-19 21:01:30 | belopolsky | set | messageid: <1468962090.7.0.636707577928.issue27576@psf.upfronthosting.co.za> |
2016-07-19 21:01:30 | belopolsky | link | issue27576 messages |
2016-07-19 21:01:30 | belopolsky | create | |
|