9 ms·
orjson is great, it's not quite a drop-in replacement, but in a good way... With orjson, encoding produces a bytes object instead of a string object, and when
by scaramanga 4y ago
orjson is great, it's not quite a drop-in replacement, but in a good way...
With orjson, encoding produces a bytes object instead of a string object, and when you're writing to a file that avoids a bunch of extra memory management overhead and a str.encode() when the text-file wrapper converts that string to a bytes behind the scenes. So that interface change is quite a big performance win over and above just having the faster JSON encoder.