4 ms·
I love zigzag encoding. The way it uses shift and xor is beautiful. It gives it a performance edge of 3 cycles on my cpu versus signed-leb encoding. One thing I
by jart 4y ago
I love zigzag encoding. The way it uses shift and xor is beautiful. It gives it a performance edge of 3 cycles on my cpu versus signed-leb encoding. One thing I did once, to encode UNICODE lookup tables in a smaller form (to reduce Python binary size) is I found out it can be very profitable to (1) delta encode; then (2) zig zag encode it; and finally (3) apply deflate. For example:
_PyUnicode_PhrasebookOffset2: size is 178,176 bytes
_PyUnicode_PhrasebookOffset2: packed size is 100,224 bytes
_PyUnicode_PhrasebookOffset2: rle size is 282,216 bytes
_PyUnicode_PhrasebookOffset2: deflate size is 52,200 bytes
_PyUnicode_PhrasebookOffset2: bz2 size is 76,876 bytes
_PyUnicode_PhrasebookOffset2: δleb size is 47,198 bytes
_PyUnicode_PhrasebookOffset2: δzd size is 12,748 bytes
It's so cool.
- lucb1e 4y agoFor anyone else not familiar: δ is a lowercase delta (at least, I had to look it up)