BurntNail / katashift_comments

0 stars 0 forks source link

Integer Compression :: KataShift #4

Open utterances-bot opened 23 hours ago

utterances-bot commented 23 hours ago

Integer Compression :: KataShift

Why use many byte when few byte do trick?

https://blog.maguire.tech/posts/explorations/integercmp/

hsfzxjy commented 23 hours ago

I believe varint is more efficient. You don't need a full byte to track the integer byte length.

BurntNail commented 23 hours ago

I believe varint is more efficient. You don't need a full byte to track the integer byte length.

I think it probably depends on your specific usecase - Bincode's varint optimises for having the most small numbers at a possible cost of empty bytes later in the integer storage which gives their max of 251, rather than my max of 247. I think it's worth it to lose a few more spaces for integers that have a non-power-of-two number of bytes, but I could see the worth in small bytes between 247 and 251.