mre/hyperjson

Speed up boolean encoding/decoding

開放

#68 建立於 2019年9月21日

 (1 則留言) (0 個反應) (0 位負責人)Python (41 個分叉)github user discovery
enhancementgood first issuehacktoberfesthelp wanted

倉庫指標

星標
 (511 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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:

https://github.com/mre/hyperjson/blob/ded13b4100638aa32fe19dc477f5cfe3e704893c/src/lib.rs#L475-L480

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?

貢獻者指南