jmespath / jmespath/jmespath.rb
Optimized expressions are not cached
- Dominant language
- Ruby
- Stars
- 167
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
By default `JMESPath#search` caches parsed expressions in order to improve performance. However, it also takes care to call `#optimize` on each expression. The optimized expressions are not cached, meaning that for every `#search` the optimization takes place.
According to my (limited) tests, caching the optimized expressions increases the performance by 10-30 times.
I see two ways to solve this;
- Cache the optimized expressions within `Runtime`, instead of caching the non-optimized expressions in the `CachingParser`, or
- Make `#optimize` memoize its result, so that sub-sequent calls can return the value directly without the overhead
I'll happily help with the coding, but wanted to get some feedback first.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.