You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a real shame that there's no C implementation of encode_basestring - so the ensure_ascii=False codepath is so slow.
I don't really have enough context to fully understand it, but it looks to me like encode_basestring ought to be simpler to implement in C than py_encode_basestring_ascii, which of course already has a C implementation.
The text was updated successfully, but these errors were encountered:
It shouldn't be more complicated, it just didn't get implemented because we weren't using that code path. If you'd like to try your hand at a PR I'd be happy to collaborate on it to get it merged.
I came here to open an issue about it, but there was one already open.
The default implementation in python 3.7 does not have this problem (it is actually faster when set to False)
In [22]: %timeit s = simplejson.dumps(xj, ensure_ascii=False)
8.17 ms ± 279 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [23]: %timeit s = simplejson.dumps(xj, ensure_ascii=True)
3.43 ms ± 201 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [25]: %timeit s = json.dumps(xj, ensure_ascii=False)
3.19 ms ± 102 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [24]: %timeit s = json.dumps(xj, ensure_ascii=True)
3.42 ms ± 338 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
It's a real shame that there's no C implementation of
encode_basestring
- so theensure_ascii=False
codepath is so slow.I don't really have enough context to fully understand it, but it looks to me like
encode_basestring
ought to be simpler to implement in C thanpy_encode_basestring_ascii
, which of course already has a C implementation.The text was updated successfully, but these errors were encountered: