Skip to content

Cache paths returned from Pooch to avoid repeated checksum in unit tests #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SimonHeybrock
Copy link
Member

This seems to save, e.g., 0.3 seconds a whole bunch of times. Not huge but noticeable. Is it a good idea?

This seems to save, e.g., 0.3 seconds a whole bunch of times. Not huge
but noticeable. Is it a good idea?
Copy link
Member

@jl-wynen jl-wynen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this code spread out across most (all?) of our packages. And it is slightly different everywhere. Can we move this to a common location so that we benefit from caching everywhere?

@@ -18,6 +19,7 @@ def __init__(self, instrument: str, files: dict[str, str], version: str):
def __contains__(self, key):
return key in self._registry.registry

@cache # noqa: B019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a comment why it is ok to cache self in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants