Skip to content
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

Only calculate bindings (ctxt_obj and ctxt_dict) once for expr slots #29

Merged
merged 1 commit into from
May 3, 2024

Conversation

martinwellman
Copy link
Collaborator

This PR deals with issue #27, and only addresses point 1 in that issue. It addresses a performance issue with expr slots in a slot_derivation. Point 1 was that the bindings for the expr are recalcualted any time an expr slot is found, and the recalculation occurs even if the bindings are the same. This is found in ObjectTransformer.map_object() where expr slots are handled. The bindings should only be calculated once. To deal with this I added the variables ctxt_obj and ctxt_dict (initialized to None) outside of the slot_derivations loop in ObjectTransformer.map_object. When an expr slot is encountered, the bindings (ctxt_obj and ctxt_dict) are only calculated if ctxt_obj is None, and the results assigned to ctxt_obj and ctxt_dict to be reused in a future iteration of the loop.

A more complex solution that deals with both points 1 and 2 in the issue is found in expr-opt-a (the second point being that only bindings that are required should be calculated, instead of all bindings, which is helpful performance-wise for very wide datasets).

Fixes #27

@cmungall cmungall merged commit bd6cea2 into main May 3, 2024
5 checks passed
@cmungall cmungall deleted the expr-opt-b branch May 3, 2024 21:55
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.

Performance for calculating bindings used by expr slot derivations
2 participants