mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
This commit is contained in:
parent
12e94200c0
commit
cdcf887999
2 changed files with 23 additions and 0 deletions
|
@ -243,6 +243,10 @@ class DictTest(unittest.TestCase):
|
|||
|
||||
self.assertRaises(Exc, baddict2.fromkeys, [1])
|
||||
|
||||
# test fast path for dictionary inputs
|
||||
d = dict(zip(range(6), range(6)))
|
||||
self.assertEqual(dict.fromkeys(d, 0), dict(zip(range(6), [0]*6)))
|
||||
|
||||
def test_copy(self):
|
||||
d = {1:1, 2:2, 3:3}
|
||||
self.assertEqual(d.copy(), {1:1, 2:2, 3:3})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue