Skip to content

Commit

Permalink
replace homegrown memoized with functools.cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dmeliza committed Jan 2, 2025
1 parent 86ee3c7 commit be90646
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
9 changes: 4 additions & 5 deletions arfx/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import logging
import os
import sys
from functools import cache

import arf
import h5py as h5
Expand Down Expand Up @@ -367,10 +368,8 @@ def copy_entries(tgt, files, **options):

from h5py import Group

from .tools import memoized

ebase = options.get("template", None)
acache = memoized(arf.open_file)
acache = cache(arf.open_file)

with arf.open_file(tgt, "a") as arfp:
arf.check_file_version(arfp)
Expand All @@ -381,8 +380,8 @@ def copy_entries(tgt, files, **options):
# on windows, dir\file.arf/entry is an entry
pn, fn = pp.split(f)
if os.path.isfile(f):
it = ((f, entry) for ename, entry in acache(f).items())
elif os.path.isfile(pn):
it = ((f, entry) for ename, entry in acache(f, mode="r").items())
elif os.path.isfile(pn, mode="r"):
fp = acache(pn)
if fn in fp:
it = ((pn, fp[fn]),)
Expand Down
37 changes: 0 additions & 37 deletions arfx/tools.py

This file was deleted.

2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit be90646

Please sign in to comment.