-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extended json serialization #511
Conversation
Thank you! I like the functionality. I'm a little worried this will make logging slower, but I guess you only hit the path if it's not one of the types orjson already supports, so that's a start. Making things faster:
Will try to take a deeper look later this week. |
I checked and deleted those types that are serialized natively by orjson. It was a bit surprising that for example it could serialize datetime but failed on date and time separately. I do not think that several if-else will significantly slowdown the logging. If we can merge this PR I am open to continue and suggest the separate one with dispatch, but it should be separate PR as it will take time to agree on best apporach |
I'm also having a problem with Paths and other serializations. Wrapping random stuff in str() is tedious, what's missing in this PR for it to be merged? Isn't functools dispatch a bit slower than isinstance chain? |
@winternewt There's nothing stopping you from writing your own serialization code, Eliot has very easy ability to add custom destination for your logs: https://eliot.readthedocs.io/en/stable/outputting/output.html#configuring-logging-output. |
This will get merged when I have some free time. |
Oh, and the FileDestination constructor lets you override the So certainly it would be nicer to have this built-in, but there's really nothing stopping you from customizing JSON serialization in your own code. |
Was looking through and found this PR. It could be a pretty useful feature. |
I've created my own branch based on this, going to go work on this now. |
Will re-open PR with new branch when done updating. Thank you for working on this! |
This feature is now released, as part of 1.17.5. Thank you! |
I added more types for json serialization and tests for them. The tests run only if the libraries are installed.