mirror of
https://github.com/python/cpython
synced 2024-10-14 10:48:24 +00:00
gh-107089: Improve Shelf.clear method performance (gh-107090)
This commit is contained in:
parent
11c055f5ff
commit
810d5d87d9
|
@ -226,6 +226,13 @@ def __init__(self, filename, flag='c', protocol=None, writeback=False):
|
||||||
import dbm
|
import dbm
|
||||||
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
|
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):
|
def open(filename, flag='c', protocol=None, writeback=False):
|
||||||
"""Open a persistent dictionary for reading and writing.
|
"""Open a persistent dictionary for reading and writing.
|
||||||
|
|
|
@ -289,6 +289,7 @@ Edward Catmur
|
||||||
Lorenzo M. Catucci
|
Lorenzo M. Catucci
|
||||||
Bruno Cauet
|
Bruno Cauet
|
||||||
Donn Cave
|
Donn Cave
|
||||||
|
James Cave
|
||||||
Charles Cazabon
|
Charles Cazabon
|
||||||
Jesús Cea Avión
|
Jesús Cea Avión
|
||||||
Per Cederqvist
|
Per Cederqvist
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Shelves opened with :func:`shelve.open` have a much faster :meth:`clear`
|
||||||
|
method. Patch by James Cave.
|
Loading…
Reference in a new issue