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
Since the core of channels are JSON messages it'd be cool if we could swap the JSON encoder of the default backends.
My use-case for this is using an encoder that supports inlining the bytes of a pre-encoded JSON objects into a larger dynamic JSON structure (we use metamagic.json package). This saves a cubic ton of CPU cycles on JSON decoding/encoding if you re-use a lot of cachable sub-structures.
Anyway, maybe a json.dumps setting would be good, like a importable path to a callable (defaulting to standard json.dumps). Alternately we could override the default backends but that's a bit too much.
A bonus this also saves the project from the endless json/simplejson/ujson/whateverfastestjsonoftheday debates. 😉
The text was updated successfully, but these errors were encountered:
There's no need to have this pluggable separately - the channel backend already gets to dictate which serialiser it uses (it just gets passed dicts and is expected to return dicts), so to change this would just mean writing a custom backend with a new serialiser, inheriting from the main one you want to use. I'll make sure the serialise/deserialise functions are broken out into class functions that can be overridden.
Since the core of channels are JSON messages it'd be cool if we could swap the JSON encoder of the default backends.
My use-case for this is using an encoder that supports inlining the bytes of a pre-encoded JSON objects into a larger dynamic JSON structure (we use
metamagic.json
package). This saves a cubic ton of CPU cycles on JSON decoding/encoding if you re-use a lot of cachable sub-structures.Anyway, maybe a
json.dumps
setting would be good, like a importable path to a callable (defaulting to standardjson.dumps
). Alternately we could override the default backends but that's a bit too much.A bonus this also saves the project from the endless json/simplejson/ujson/whateverfastestjsonoftheday debates. 😉
The text was updated successfully, but these errors were encountered: