mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Don't write "if self.dict: self.dict.close()"; just write
"self.dict.close()" and ignore the exception. The "if self.dict:" part would be calculated through len(self.dict.keys()), which is very expensive for a large dictionary...
This commit is contained in:
parent
3ec38f0ee4
commit
65e5399081
1 changed files with 1 additions and 2 deletions
|
@ -75,8 +75,7 @@ class Shelf:
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
try:
|
try:
|
||||||
if self.dict:
|
self.dict.close()
|
||||||
self.dict.close()
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.dict = 0
|
self.dict = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue