pysimdjson
pysimdjson copied to clipboard
Add alias to `json.JSONEncoder` to drop-in API.
The docs explicitly call out a Drop-in API which will "just work". This module covers json.{load,loads,dump,dumps}, where {dump,dumps} are aliased to the built-in module. I propose adding an alias to json.JSONEncoder to make the drop-in API more complete. I don't think this should be problematic as one would only use a JSONEncoder for the dump/s commands, which are already aliased.
In a current project, I have something like this:
from json import JSONEncoder
try:
import simdjson as json
except ImportError:
import json
class CustomEncoder(JSONEncoder):
...
If an alias is added, the above snippet would be:
try:
import simdjson as json
except ImportError:
import json
class CustomEncoder(json.JSONEncoder):
...
It's a rather minor tweak, but I think it would be nice for developer experience.
Cheers