Skip to content

Optimized expressions are not cached #25

@bjorne

Description

@bjorne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions