Skip to content

Python JSONPath Version 2 #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Python JSONPath Version 2 #98

wants to merge 4 commits into from

Conversation

jg-rp
Copy link
Owner

@jg-rp jg-rp commented Aug 9, 2025

Looking ahead to Python JSONPath version 2, this PR includes breaking changes for both the Python API and some subtle changes to the default JSONPath syntax. We have:

  • Changed the lexer so it emits more punctuation and whitespace tokens. Previously we broadly skipped some punctuation and whitespace. Now the parser can make better choices about when to accept whitespace and do a better job of enforcing dots.
  • Rewritten the parser and its token stream. It should now be more correct and easier to read.
  • Changed the internal representation of JSONPath segments and selectors. We now model segments explicitly.
  • Renamed "fake root" to "pseudo-root"
  • Dropped support for unquoted property names in bracketed segments.

More changes to follow before release:

  • Implement the Singular path selector.
  • Implement the keys filter selector.
  • Remove shorthand arguments to some selector classes. We no longer need them.
  • Improve leading and trailing whitespace handling options so users can choose how strict to be.

@jg-rp
Copy link
Owner Author

jg-rp commented Aug 10, 2025

Some JSONPath performance notes, before attempting any new optimizations.

This benchmark is run on lots of small JSONPath queries with small data.

Main branch (89c0e7e)

(python-jsonpath) james@Jamess-Mac-mini python-jsonpath % python scripts/benchmark.py 
repeating 436 queries 100 times, best of 3 rounds
compile and find               1.392
compile and find (values)      1.400
just compile                   0.917
just find                      0.392
just find (values)             0.395

V2 branch (e41ec29)

(python-jsonpath) james@Jamess-Mac-mini python-jsonpath % python scripts/benchmark.py
repeating 436 queries 100 times, best of 3 rounds
compile and find               1.461
compile and find (values)      1.471
just compile                   0.949
just find                      0.413
just find (values)             0.418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant