Skip to content

Conversation

@nicoe
Copy link
Collaborator

@nicoe nicoe commented May 8, 2024

No description provided.

nicoe added 2 commits May 8, 2024 21:37
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.
@nicoe nicoe requested a review from JCavallo May 8, 2024 19:52
JCavallo
JCavallo previously approved these changes May 14, 2024
@nicoe nicoe merged commit 3e075d0 into coopengo:master May 21, 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
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
nicoe pushed a commit to nicoe/tryton-coopengo-new that referenced this pull request Jun 16, 2025
nicoe pushed a commit to nicoe/tryton-coopengo-new that referenced this pull request Jun 19, 2025
nicoe pushed a commit to nicoe/tryton-coopengo-new that referenced this pull request Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants