Skip to content
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

DefinedNamespaceMeta.__getitem__ is slow #1718

Conversation

anatoly-scherbakov
Copy link
Contributor

@anatoly-scherbakov anatoly-scherbakov commented Feb 17, 2022

Fixes #

Proposed Changes

  • Cache the __getitem__ method to improve performance.

Copy link
Member

@aucampia aucampia left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for the PR.

@aucampia aucampia added the review wanted This indicates that the PR is ready for review label Feb 19, 2022
Copy link
Member

@white-gecko white-gecko left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a question, why not just use @cache, according to https://docs.python.org/3/library/functools.html#functools.cache it is the same as lru_cache(maxsize=None) and would be easier to read.

@aucampia
Copy link
Member

Looks good to me, just a question, why not just use @cache, according to https://docs.python.org/3/library/functools.html#functools.cache it is the same as lru_cache(maxsize=None) and would be easier to read.

@cache would be better but it is only available from 3.9.

@aucampia
Copy link
Member

Will merge this weekend if there is no further feedback.

@white-gecko
Copy link
Member

Looks good to me, just a question, why not just use @cache, according to https://docs.python.org/3/library/functools.html#functools.cache it is the same as lru_cache(maxsize=None) and would be easier to read.

@cache would be better but it is only available from 3.9.

Thank you for the clarification. I think we can merge this now.

@white-gecko white-gecko merged commit a10198e into RDFLib:master Mar 16, 2022
@anatoly-scherbakov anatoly-scherbakov deleted the issue-1717-defined-namespace-meta-getitem-is-slow branch March 17, 2022 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review wanted This indicates that the PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants