-
Notifications
You must be signed in to change notification settings - Fork 24
Optimize instance creation in __getattr__ [PREVIEW] #210
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
Merged
Conversation
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
Accessing a M2O field from a X2M field could result in as many instantiations as there are records in the X2M field. It could be a performance bottleneck due to the many creations of Model kwargs and potential useless calls of transaction.set_context(). Thus the optimization is twofold: - Create an additional code path when the M2O field modifies the context - Cache the kwargs creation process to prevent extra calls resulting in the same dictionary
Using a browse there in order to get the id is a performance bottleneck as it will result in the instanciation of potentially thousands of models.
JCavallo
previously approved these changes
May 14, 2024
JCavallo
approved these changes
May 16, 2024
nicoe
added a commit
that referenced
this pull request
May 21, 2024
* Optimize instance creation in __getattr__ [PREVIEW] Accessing a M2O field from a X2M field could result in as many instantiations as there are records in the X2M field. It could be a performance bottleneck due to the many creations of Model kwargs and potential useless calls of transaction.set_context(). Thus the optimization is twofold: - Create an additional code path when the M2O field modifies the context - Cache the kwargs creation process to prevent extra calls resulting in the same dictionary * Use read to fetch reverse field value of O2M field in get [PREVIEW] Using a browse there in order to get the id is a performance bottleneck as it will result in the instanciation of potentially thousands of models. --------- Co-authored-by: Jean Cavallo <jean.cavallo@hotmail.fr>
JCavallo
added a commit
that referenced
this pull request
May 21, 2024
* Optimize instance creation in __getattr__ [PREVIEW] Accessing a M2O field from a X2M field could result in as many instantiations as there are records in the X2M field. It could be a performance bottleneck due to the many creations of Model kwargs and potential useless calls of transaction.set_context(). Thus the optimization is twofold: - Create an additional code path when the M2O field modifies the context - Cache the kwargs creation process to prevent extra calls resulting in the same dictionary * Use read to fetch reverse field value of O2M field in get [PREVIEW] Using a browse there in order to get the id is a performance bottleneck as it will result in the instanciation of potentially thousands of models. --------- Co-authored-by: Jean Cavallo <jean.cavallo@hotmail.fr>
nicoe
pushed a commit
to nicoe/tryton-coopengo-new
that referenced
this pull request
Sep 3, 2024
… modification [CUSTOM] (coopengo#210) Fix #PMETA-81
nicoe
added a commit
to nicoe/tryton-coopengo-new
that referenced
this pull request
Sep 3, 2024
* Optimize instance creation in __getattr__ [PREVIEW] Accessing a M2O field from a X2M field could result in as many instantiations as there are records in the X2M field. It could be a performance bottleneck due to the many creations of Model kwargs and potential useless calls of transaction.set_context(). Thus the optimization is twofold: - Create an additional code path when the M2O field modifies the context - Cache the kwargs creation process to prevent extra calls resulting in the same dictionary * Use read to fetch reverse field value of O2M field in get [PREVIEW] Using a browse there in order to get the id is a performance bottleneck as it will result in the instanciation of potentially thousands of models. --------- Co-authored-by: Jean Cavallo <jean.cavallo@hotmail.fr>
jmousset
pushed a commit
to jmousset/tryton
that referenced
this pull request
Jan 9, 2025
… modification [CUSTOM] (coopengo#210) Fix #PMETA-81
nicoe
pushed a commit
to nicoe/tryton-coopengo-new
that referenced
this pull request
Jun 16, 2025
… modification [CUSTOM] (coopengo#210) Fix #PMETA-81
nicoe
pushed a commit
to nicoe/tryton-coopengo-new
that referenced
this pull request
Jun 19, 2025
… modification [CUSTOM] (coopengo#210) Fix #PMETA-81
nicoe
pushed a commit
to nicoe/tryton-coopengo-new
that referenced
this pull request
Sep 11, 2025
… modification [CUSTOM] (coopengo#210) Fix #PMETA-81
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.
No description provided.