mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-107089: Improve Shelf.clear method performance (gh-107090)
This commit is contained in:
parent
11c055f5ff
commit
810d5d87d9
3 changed files with 10 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue