Don't automatically set instantiate to True when constant is True #776
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.
Fixes #287
Pushing this WIP PR to get some feedback on the approach. The idea is that when:
instantiateisTrue-> deepcopydefaultand assign it to the local cache (pseudo:parameterized_obj._X_param_value = deepcopy(parameter.default))constantisTrue-> don't deepcopy, just assign a reference todefaultto the local cache (pseudo:parameterized_obj._X_param_value = parameter.default)With 1. taking precedence over 2.
The test added in 7635d55 and that is based on the one given in the issue passes with this change.
Of course this means that if the
defaultobject is mutable, any change made from a reference will be seen by all the other references, all pointing to the same updated object.If reviewers are OK with this approach, I'll need to clean up the code and do some refactoring, it's a bit hacky right now.