This repository was archived by the owner on Sep 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
This repository was archived by the owner on Sep 14, 2023. It is now read-only.
Speed up boolean encoding/decoding #68
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needed
Description
From our benchmarks we can see that we are consistently slower than everyone else when serializing/deserializing boolean values. We should fix that.
orjson is using an unsafe block to create a reference to a boolean:
https://github.com/ijl/orjson/blob/03d55e99a953ce93cedc05f03e4b63b0bcbbcc7a/src/decode.rs#L81-L96
This avoids additional allocations.
For comparison, this is our code at the moment:
Lines 475 to 480 in ded13b4
| fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E> | |
| where | |
| E: de::Error, | |
| { | |
| Ok(value.to_object(self.py)) | |
| } |
I wonder if we could achieve comparable performance without using unsafe.
@konstin, any idea? Maybe there was a recent development in pyo3 that we could leverage here?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needed