Only calculate bindings (ctxt_obj and ctxt_dict) once for expr slots #29
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.
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