remove Scopes LRU caching

This commit is contained in:
Yacine Elhamer
2023-08-01 20:09:42 +01:00
parent 462024ad03
commit a85e0523f8
2 changed files with 1 additions and 24 deletions

View File

@@ -132,25 +132,6 @@ def redirecting_print_to_tqdm(disable_progress):
inspect.builtins.print = old_print # type: ignore
def weak_lru(maxsize=128, typed=False):
"""
LRU Cache decorator that keeps a weak reference to 'self'
"""
def wrapper(func):
@functools.lru_cache(maxsize, typed)
def _func(_self, *args, **kwargs):
return func(_self(), *args, **kwargs)
@functools.wraps(func)
def inner(self, *args, **kwargs):
return _func(weakref.ref(self), *args, **kwargs)
return inner
return wrapper
def log_unsupported_format_error():
logger.error("-" * 80)
logger.error(" Input file does not appear to be a PE or ELF file.")

View File

@@ -16,7 +16,7 @@ import collections
from enum import Enum
from pathlib import Path
from capa.helpers import weak_lru, assert_never
from capa.helpers import assert_never
try:
from functools import lru_cache
@@ -115,10 +115,6 @@ class Scopes:
static: Optional[str] = None
dynamic: Optional[str] = None
@weak_lru()
def __new__(cls, *args, **kwargs):
return super().__new__(cls)
def __contains__(self, scope: Union[Scope, str]) -> bool:
assert isinstance(scope, (Scope, str))
return (scope == self.static) or (scope == self.dynamic)