-
Notifications
You must be signed in to change notification settings - Fork 180
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
[python] Allow use of other JSON encoder/decoders #1654
Comments
Hey @bollwyvl! Thanks for the suggestion. That sounds like a huge win. If it can be accomplished by monkeypatching, is it just a drop in replacement we could use? Do you know if it supports the same platforms/versions that we support? Either way, sounds like having a feature like |
Welp, as But again, "picking a horse" might not be as effective as "leaving an open stable," and letting downstreams do their own shim around it, with proper docs and types of what it might ask for in e.g. This would leave the way for exploring options, dependent on the workload, e.g. |
Per https://pypi.org/project/orjson/ I personally agree that a more generic setter pattern (though I'd probably use a Thanks 🙂 |
Well, if there's always "The One True" oso at any given time, it could just be in the constructor: oso = Oso(
json_loads: Callable[[Any], str] = json.loads,
json_dumps: Callable[[str], Any] = json.dumps
) And it's up to the implementer to overload the default by subclass or instantiation |
Thanks for oso!
It would be lovely if there was a simple way for
polar
to make use of other, more performant JSON encoder/decoder libraries.For example, by monkeypatching the rust-based
orjson
intopolar.(cffi|query|errors)
, I've observed calls tojson.loads
pretty much disappearing into noise when profiled withpyinstrument
, whereas previously it was rather pronounced.The text was updated successfully, but these errors were encountered: