-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
switch back to stdlib json #7674
Comments
see also: #3009, matrix-org/python-canonicaljson#23 |
Did a little experimenting, and it turns out that:
So if canonicaljson is changed to use the stdlib |
Actually it's even worse than that: some of the C-S handlers also return |
to demonstrate the problem:
|
I think it was mentioned in #synapse-dev:matrix.org, but I believe the first step of this was to fix the places where Synapse passes bytes into canonicaljson. |
Next steps on this:
While we're working on |
Looks like we also directly use |
The build in #7803 passed, which means that current develop can run with the standard library JSON module. I don't think we can just merge matrix-org/python-canonicaljson#24 and release canonicaljson though since older Synapse's might upgrade to this newer version of canonicaljson, which would break them. We could release a Synapse which sets a maximum version of canonicaljson to the current version, then release canonicaljson and remove the max limit in Synapse? Not sure if there's a better way to do that. |
A few more options from Rich (see conversation):
This seems plausible, although is a bit ugly.
This would work, but means we'll have to constantly recreate JSON encoders, which would probably have a performance impact. (Or I guess we could have an initialization function which would get called to initialize the encoders or something?)
This would work fine, but will require changing the package and module names, updating Synapse to use
I assume there was a good reason to have this be a separate library in the first place, not sure if those reasons are still valid. I think the easiest way forward is the first option:
The major downside for any of the options that have us keeping support for older Synapses in canonicaljson is that matrix-org/python-canonicaljson#24 cannot be merged, we can tweak something so that most of the benefits are used though. The only way I see around that is releasing it as a canonicaljson2 library. |
My current plan for this is:
I think this is tenable and isn't too much of a faff. |
While workin gon #7670 I realized that this isn't fully done. We do use the standard library JSON for all all canonicaljson operations, but not for other operations. There's a handful of places that we
Any thoughts on which of these is the "right" way to go? |
I'm inclined towards the former. Seems simpler? |
That was my thought too. I think importing from canonicaljson is actually just a bit confusing. Especially now that we explicitly declare we want to use the json from the standard library. |
I found my benchmark data and it looks like stdlib json is faster than simplejson for dumping data nowadays.
Using python 3.7.5 (seconds per loop: smaller is better):
The text was updated successfully, but these errors were encountered: