Support expressions in selectattr/rejectattr again, more efficiently #450
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.
Redoes the changes made (and reverted) in #238 to support full expressions as the first argument to the
selectattr
filter. The previous approach caused performance issues because of the generation of a unique expression for each value processed in the sequence. These expressions all get saved in the context (code), making iterating through resolved expressions and even just checking membership in the set (code) unwieldy.This PR uses the same expression string for processing each value and removes it from the context after we've finished iterating through the loop. Doing so not only avoids the bloated context issue, but also allows us to take advantage of caching in the
TreeStore
when parsing the expression string into aTreeValueExpression
.Locally testing this implementation on very large lists (of 10,000 elements) showed that performance is the same, if not slightly faster, than the current master branch implementation that only supports chained attributes, and an order of magnitude faster than the #238 implementation with unique expressions.