-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Restore __slots__ to core objects #127441
Merged
Merged
Conversation
This file contains 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
propcache is derived from yarl which uses an accelerated cached_property implementation. It also has an under_cached_property implementation which stores the cache in self._cache which is compatiblity with __slots__ which will allow use to restore __slots__ to many objects that we had to remove it from to allow for the stdlib @cached_property which does not support __slots__ Currently yarl and aiohttp both implement the same property caching code and cython code. The goal of the propcache library is to replace both implementations in yarl and aiohttp and maintain it in a single place in aiohttp 3.11 propcache is expected to replace the internal yarl and aiohttp implementations.
…t_cached_property
epenet
reviewed
Oct 3, 2024
31 tasks
bdraco
changed the title
DNM: Restore __slots__ to core objects
Restore __slots__ to core objects
Oct 3, 2024
bdraco
added a commit
to bdraco/home-assistant
that referenced
this pull request
Oct 3, 2024
same as home-assistant#127441 but for the registries
bdraco
added a commit
that referenced
this pull request
Oct 3, 2024
same as #127441 but for the registries
19 tasks
test failure is unrelated |
19 tasks
frenck
approved these changes
Oct 3, 2024
Thanks. Adding them back to the registries will require some more work since they were gone from there longer and mocks are missing some values |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Proposed change
One of the downsides to using
@cached_property
is we cannot also use__slots__
. With the@under_cached_property
we still can because the cache dict is implemented asself._cache
instead of usingself.__dict__
which__slots__
removed. Since we churn and throw away these objects frequently, the memory and creation time adds up. While the benefit of@cached_property
greatly outweighs the benefit of__slots__
its nice to be able to have both.before
after
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: