mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Improve DictMixin.
Replaced docstring with comments. Prevents subclass contamination. Added the missing __cmp__() method and a test for __cmp__(). Used try/except style in preference to has_key() followed by a look-up. Used iteritem() where possible to save creating a long key list and to save redundant lookups. Expanded .update() to look for the most helpful methods first and gradually work down to a mininum expected interface. Expanded documentation to be more clear on how to use the class.
This commit is contained in:
parent
782d940866
commit
8ddc176e2e
3 changed files with 52 additions and 37 deletions
|
@ -210,9 +210,8 @@ else:
|
|||
s.update({10: 'ten', 20:'twenty'}) # update
|
||||
verify(s[10]=='ten' and s[20]=='twenty')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
verify(s == {10: 'ten', 20:'twenty'}) # cmp
|
||||
t = SeqDict()
|
||||
t[20] = 'twenty'
|
||||
t[10] = 'ten'
|
||||
verify(s == t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue