fix: read _sockets_dict in Sockets.__getattribute__ - #12966
Open
bhaskargurram-ai wants to merge 1 commit into
Open
bhaskargurram-ai wants to merge 1 commit into
bhaskargurram-ai wants to merge 1 commit into
Conversation
__getattribute__ looked up a `_sockets` attribute, but the one __init__ assigns is `_sockets_dict`. The lookup raised AttributeError on every attribute access and fell through to object.__getattribute__, so the intended fast path never ran. Socket access still worked, but only through the copy __init__ places in __dict__ -- which made the dead branch look load-bearing and put an exception on the path of every attribute access. Reading the right name makes the branch live: 200k socket attribute accesses drop from 0.125s to 0.031s. External behaviour is unchanged, since the __dict__ copy already shadowed class attributes for the same names. Fixes deepset-ai#12939
bhaskargurram-ai
requested review from
julian-risch
and removed request for
a team
September 25, 2026 21:28
Contributor
|
@bhaskargurram-ai is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @bhaskargurram-ai, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
HaystackBot
marked this pull request as draft
September 25, 2026 22:51
HaystackBot
marked this pull request as ready for review
September 25, 2026 23:25
Contributor
|
Thanks for signing the CLA, @bhaskargurram-ai! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
This branch has not been deployed
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.
getattribute looked up a
_socketsattribute, but the one init assigns is_sockets_dict. The lookup raised AttributeError on every attribute access and fell through to object.getattribute, so the intended fast path never ran.Socket access still worked, but only through the copy init places in dict -- which made the dead branch look load-bearing and put an exception on the path of every attribute access.
Reading the right name makes the branch live: 200k socket attribute accesses drop from 0.125s to 0.031s. External behaviour is unchanged, since the dict copy already shadowed class attributes for the same names.
Fixes #12939
Related Issues
Proposed Changes:
How did you test it?
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.