Bijou64: A variable-length integer encoding

(inkandswitch.com)

33 points | by justinweiss 58 minutes ago

2 comments

  • stebalien 11 minutes ago

    I've used LEB128 (with canonicalisation) extensively and... this looks so much nicer for most use-cases (length prefixed, supports the full uint64 range without that extra 10th byte).

    The downside is the encoding size. LEB128 quickly grows to 2 bytes, but stays at 2 bytes all the way to 2^14. This is important if you're using these numbers as tags/identifiers as we were in the multicodec [1] project, or for network message lengths. bijou64 only gives you 500 <= 2 byte numbers.

    [1]: https://github.com/multiformats/multicodec

    • RedShift1 17 minutes ago

      This seems quite convoluted just to avoid the "0 can be represented in more than one way" problem.

      • nine_k 14 minutes ago

        It allows finding out the length (and allocating memory) after reading the first byte.

        • ahoka 12 minutes ago

          I think it's neat.