-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Obsoletes #291
Rather than migrating the old feature/stream-mode
API into main branch, I will be implementing a new streaming API with a more user-friendly API and modern implementation.
Currently, this CBOR codec uses Go's built-in reflect
package. Although feature/stream-mode
branch avoids using reflect
package, using the stream-mode branch requires detailed knowledge of RFC 8949.
The new stream-mode API will provide the performance of feature/stream-mode
while being more user-friendly to programmers who don't have detailed knowledge of RFC 8949.
Also, programs using the new streaming API benefit from improved compatibility with TinyGo compiler.
The upcoming encoding/json/v2
has some great ideas and I would like to avoid reinventing the wheel when it makes sense, but CBOR has more features (e.g., CBOR tags) and a more extensive data model than JSON so there will be differences.
I will open a discussion about the API after working out a few more details in a proof-of-concept I've been exploring during weekends.
There are a handful of open issues this can address and I will link this issue to them after we have public discussions about the new streaming API.
Notes
This weekend (July 20), I stumbled across an old comparison (both benchmarks use this library).
This comparison shows standard API (enc.Encode
) is slower vs old streaming API of this library.
name time/op alloc/op allocs/op
UintWriteCbor-8 69.1ns ± 0% 19.0B ± 0% 0
UintStreamWriteCbor-8 10.1ns ± 1% 16.0B ± 0% 0
* Go 1.17 linux_amd64 (Haswell Xeon)