h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
572 stars 85 forks source link

[Feature Request] Support executing with -OO or OPTIMIZE=2 #121

Open mgiamberardino opened 1 year ago

mgiamberardino commented 1 year ago

PLY has the option to support running in optimized mode if we can somehow generate the tables on a first run: PLY - Using Python's Optimized Mode

If instead of compiling the parser each time we could generate and store them with write_tables=1 we could still run jsonpath-ng using -OO.

def __init__(self, debug=False, lexer_class=None):
        if self.__doc__ is None:
            raise JsonPathParserError(
                'Docstrings have been removed! By design of PLY, '
                'jsonpath-rw requires docstrings. You must not use '
                'PYTHONOPTIMIZE=2 or python -OO.'
            )
jkugler commented 9 months ago

Also, the author of PLY created SLY: https://github.com/dabeaz/sly which is more programmatic , and thus doesn't require doc strings. And I'm sure there are other parsers out there which don't require doc strings. This would be a great enhancement, as running -OO is a rather common thing.

jkugler commented 9 months ago

Also, in your search for a new parser, finding a parser which is compatible with Apache/MIT/BSD might be good. The fact that PLY has no license could be problematic for some organizations. It looks like SLY has a BSD license which would be a good choice.