[Haskell-cafe] Re: [Haskell] ANNOUNCE: binary: high performance, pure binary serialisation

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Jan 26 11:56:29 EST 2007

Tomasz Zielonka <tomasz.zielonka at gmail.com> wrote:

> Did you consider using an encoding which uses variable number of
> bytes? If yes, I would be interested to know your reason for not
> choosing such an encoding. Efficiency?

My Binary implementation (from 1998) used a type-specific number of bits
to encode the constructor - exactly as many as needed.  (If you were
writing custom instances, you could even use a variable number of bits
for the constructor, e.g. using Huffman encoding to make the more common
constructors have the shortest representation.)

The latter certainly imposes an extra time overhead on decoding, because
you cannot just take a fixed-size chunk of bits and have the value.  But
I would have thought that in the regular case, using a type-specific
(but not constructor-specific) size for representing the constructor
would be very easy and have no time overhead at all.


More information about the Haskell-Cafe mailing list