If orjson is faster than stdlib json, then why is its implementation or algo not used in CPython?

Is it mainly because orjson is not a drop-in replacement? I see that it doesn’t support all the arguments supported stdlib json.

Or is there something simple that I’m missing. Just curious.

It’s written in Rust, so you can’t directly translate it to a C extension. It would be better to look at ujson, as it’s written in C. Rewriting it to be be backwards compatible would be a lot of work though, and be difficult to maintain.

We’re better off incrementally improving the code. jsonyx is already a bit faster than the standard library, but there’s still a long way to go. See GitHub - nineteendo/jsonyx-performance-tests.

That’s not really a good argument to pull something into the standard library - when an even faster library gets written (msgspec?), do we remove orjson (can’t, because of backwards comp) or add it too (and we end up with dozens of json libs over the decades)?

There’s also a cost to libraries moving into the stdlib, for example maintaining stricter backwards comp and being tied to the CPython release schedule.

There are faster implementations of JSON written in C (msgspec), but that alone doesn’t justify adding their complexity to the standard library.