diff options
author | James Cave <jcave137@gmail.com> | 2023-07-29 00:08:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-29 00:08:11 (GMT) |
commit | 810d5d87d9fe8d86aad99e48cef4f78a72e16ccf (patch) | |
tree | 3d5155864548a0ad86aeadb1ea009c9ffa99078e /Lib | |
parent | 11c055f5ff1a353de6d2e77f2af24aaa782878ba (diff) | |
download | cpython-810d5d87d9fe8d86aad99e48cef4f78a72e16ccf.zip cpython-810d5d87d9fe8d86aad99e48cef4f78a72e16ccf.tar.gz cpython-810d5d87d9fe8d86aad99e48cef4f78a72e16ccf.tar.bz2 |
gh-107089: Improve Shelf.clear method performance (gh-107090)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/shelve.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py index e053c39..5058471 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -226,6 +226,13 @@ class DbfilenameShelf(Shelf): import dbm Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) + def clear(self): + """Remove all items from the shelf.""" + # Call through to the clear method on dbm-backed shelves. + # see https://github.com/python/cpython/issues/107089 + self.cache.clear() + self.dict.clear() + def open(filename, flag='c', protocol=None, writeback=False): """Open a persistent dictionary for reading and writing. |