From abedf5e146f9da1f62219eac4c181867f429b144 Mon Sep 17 00:00:00 2001 From: Jeremy Howard Date: Mon, 15 Jul 2024 08:10:12 +1000 Subject: [PATCH] cleanup --- fastcore/xtras.py | 8 ++++---- nbs/03_xtras.ipynb | 18 ------------------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/fastcore/xtras.py b/fastcore/xtras.py index 44f6a731..b48a1177 100644 --- a/fastcore/xtras.py +++ b/fastcore/xtras.py @@ -686,7 +686,7 @@ def mk_dataclass(cls): setattr(cls, k, field(default=None)) dataclass(cls, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False) -# %% ../nbs/03_xtras.ipynb 181 +# %% ../nbs/03_xtras.ipynb 179 def flexicache(*funcs, maxsize=128): "Like `lru_cache`, but customisable with policy `funcs`" def _f(func): @@ -711,7 +711,7 @@ def wrapper(*args, **kwargs): return wrapper return _f -# %% ../nbs/03_xtras.ipynb 183 +# %% ../nbs/03_xtras.ipynb 181 def time_policy(seconds): "A `flexicache` policy that expires cached items after `seconds` have passed" def policy(last_time): @@ -719,7 +719,7 @@ def policy(last_time): return now if last_time is None or now-last_time>seconds else None return policy -# %% ../nbs/03_xtras.ipynb 184 +# %% ../nbs/03_xtras.ipynb 182 def mtime_policy(filepath): "A `flexicache` policy that expires cached items after `filepath` modified-time changes" def policy(mtime): @@ -727,7 +727,7 @@ def policy(mtime): return current_mtime if mtime is None or current_mtime>mtime else None return policy -# %% ../nbs/03_xtras.ipynb 187 +# %% ../nbs/03_xtras.ipynb 185 def timed_cache(seconds=60, maxsize=128): "Like `lru_cache`, but also with time-based eviction" return flexicache(time_policy(seconds), maxsize=maxsize) diff --git a/nbs/03_xtras.ipynb b/nbs/03_xtras.ipynb index 8f01d4a4..1f1eb76d 100644 --- a/nbs/03_xtras.ipynb +++ b/nbs/03_xtras.ipynb @@ -2840,24 +2840,6 @@ "Person(name=\"Bob\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "d = dict(a=1,b=2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "d.popitem()" - ] - }, { "cell_type": "code", "execution_count": null,