summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-03-26 22:12:22 (GMT)
committerGuido van Rossum <guido@python.org>1998-03-26 22:12:22 (GMT)
commit65e5399081e23d7b1efbf685096c65d0a0ab912b (patch)
tree01e6410fbc78bdbcdc684e004b032fc37d995813 /Lib
parent3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 (diff)
downloadcpython-65e5399081e23d7b1efbf685096c65d0a0ab912b.zip
cpython-65e5399081e23d7b1efbf685096c65d0a0ab912b.tar.gz
cpython-65e5399081e23d7b1efbf685096c65d0a0ab912b.tar.bz2
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...
Diffstat (limited to 'Lib')
-rw-r--r--Lib/shelve.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 9b65a09..6bdc030 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -75,8 +75,7 @@ class Shelf:
def close(self):
try:
- if self.dict:
- self.dict.close()
+ self.dict.close()
except:
pass
self.dict = 0