py: Implement full behaviour of dict.update(), and dict().
Add keyword args to dict.update(), and ability to take a dictionary as argument. dict() class constructor can now use dict.update() directly. This patch loses fast path for dict(other_dict), but is that really needed? Any anyway, this idiom will now re-hash the dictionary, so is arguably more memory efficient. Addresses issue #647.
This commit is contained in:
16
tests/basics/dict_construct.py
Normal file
16
tests/basics/dict_construct.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# dict constructor
|
||||
|
||||
d = dict()
|
||||
print(d)
|
||||
|
||||
d = dict({1:2})
|
||||
print(d)
|
||||
|
||||
d = dict(a=1)
|
||||
print(d)
|
||||
|
||||
d = dict({1:2}, a=3)
|
||||
print(d[1], d['a'])
|
||||
|
||||
d = dict([(1, 2)], a=3, b=4)
|
||||
print(d[1], d['a'], d['b'])
|
||||
Reference in New Issue
Block a user