Skip to content
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

Make alternate json libraries a hook to replace builtin json. #4169

Closed
isaulv opened this issue Jun 19, 2017 · 3 comments
Closed

Make alternate json libraries a hook to replace builtin json. #4169

isaulv opened this issue Jun 19, 2017 · 3 comments

Comments

@isaulv
Copy link

isaulv commented Jun 19, 2017

Currently, in the _compat.py module, if you have simplejson installed, it will use that over the standard built-in json.

This works fine in Python 2, since simplejson is typically faster than the built in json package, and it is more 'correct' in handling JSON.

However, in Python 3, simplejson is slower than the built in json package especially for smaller json payloads, which is probably a typical use case with the requests library. Even though simplejson handles various JSON strings better than the built in JSON, those cases are not typical.

I would like to see a hook that allows a user to opt to use a alternate JSON library so that a user can specify if they want to use rapidjson, ujson, simpleson for the response.json() decoding.

@Lukasa
Copy link
Member

Lukasa commented Jun 19, 2017

The 3.0 release of Requests will remove the use of simplejson in favour of the stdlib module. Until that time, however, we cannot safely remove the option to use simplejson, as it would potentially represent a subtle backward-incompatible dependency change.

I don't really see any reason to allow more general hooking of JSON libraries: ultimately, additional JSON features are not really a thing I think we need to support.

Thanks for your report!

@Lukasa Lukasa closed this as completed Jun 19, 2017
@SharpEdgeMarshall
Copy link

What's the breaking change?

@isaulv
Copy link
Author

isaulv commented Apr 2, 2020

@SharpEdgeMarshall replacing the dependency on simplejson in

I still think you should be able to replace the JSON library used.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants