mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-29 11:16:43 +00:00
helpers.py: replace memoize with functools.lru_cache
This commit is contained in:
parent
45fd66f6e1
commit
28076ee588
1 changed files with 2 additions and 12 deletions
|
@ -22,7 +22,7 @@
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from datetime import datetime, timezone, timedelta
|
from datetime import datetime, timezone, timedelta
|
||||||
from fnmatch import translate
|
from fnmatch import translate
|
||||||
from functools import wraps, partial
|
from functools import wraps, partial, lru_cache
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
|
@ -722,17 +722,7 @@ def format_archive(archive):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def memoize(function):
|
memoize = lru_cache(maxsize=None)
|
||||||
cache = {}
|
|
||||||
|
|
||||||
def decorated_function(*args):
|
|
||||||
try:
|
|
||||||
return cache[args]
|
|
||||||
except KeyError:
|
|
||||||
val = function(*args)
|
|
||||||
cache[args] = val
|
|
||||||
return val
|
|
||||||
return decorated_function
|
|
||||||
|
|
||||||
|
|
||||||
class Buffer:
|
class Buffer:
|
||||||
|
|
Loading…
Reference in a new issue