Conversation
ogrisel
reviewed
Sep 16, 2026
| def __getattr__(self, symbol: str) -> ctypes._CFuncPtr | None: | ||
| result = self._cache.get(symbol, _MISSING) | ||
| if result is _MISSING: | ||
| result = getattr(self._cdll, symbol, None) |
Contributor
There was a problem hiding this comment.
Out of curiosity, do you have quantitative evidence that caching attribute looks of ctypes.CDLL instances is useful? I would not have expected them to be expensive.
Contributor
Author
There was a problem hiding this comment.
It showed up in the profile, pretty sure, which is what motivated this. When I get to the final PR I will give some numbers without this enabled, and remove it turns out to be unnecessary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #246
Todo:
Additional optimizations:
getattr(CDLL, attr), e.g. OpenBLASController._find_affixes per the profiler._warn_if_incompatible_openmp()once per newly loaded CDLL, if possible, instead of every timeThreadPoolControlleris loaded.