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

Donald Bruce Stewart dons at cse.unsw.edu.au
Sat Jan 27 23:23:33 EST 2007


dons:
> lemming:
> > 
> > On Sat, 27 Jan 2007, Donald Bruce Stewart wrote:
> > 
> > > lemming:
> > > > 
> > > > On Fri, 26 Jan 2007, Donald Bruce Stewart wrote:
> > > > 
> > > > > 
> > > > >         Binary: high performance, pure binary serialisation for Haskell
> > > > >      ---------------------------------------------------------------------- 
> > > > > 
> > > > > The Binary Strike Team is pleased to announce the release of a new,
> > > > > pure, efficient binary serialisation library for Haskell, now available
> > > > > from Hackage:
> > > > >     
> > > > >  tarball:    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary/0.2
> > > > >  darcs:      darcs get http://darcs.haskell.org/binary
> > > > >  haddocks:   http://www.cse.unsw.edu.au/~dons/binary/Data-Binary.html
> > > > 
> > > > I want to write out data in the machine's endianess, because that data 
> > > > will be post-processed by sox, which reads data in the machine's 
> > > > endianess. Is this also planned for the package?
> > > 
> > > The underlying Get and Put monads support explicit endian writes and
> > > reads, which you can add to your instances explicitly:
> > > 
> > >     http://www.cse.unsw.edu.au/~dons/binary/Data-Binary-Get.html#5
> > >     http://www.cse.unsw.edu.au/~dons/binary/Data-Binary-Put.html#5
> > > 
> > > So you can do that now. 
> > 
> > Of course, I can check for the machine's endianess, then decide whether to
> > use putWord16be and putWord16le. But I assume that it is more efficient,
> > if there would be some function putWord16native, which writes out in the
> > machine's native endianess.

I've added raw primitives for:

    {put,get}Wordhost
    {put,get}Word16host
    {put,get}Word32host
    {put,get}Word64host

which do unaligned, host-sized, host-endian packing of data.

Writing is some 15% faster for Words, a bit less for reading (which is a
bit unoptimised at the moment), and a bit less for other types. Needless
to say, data serialised this way is only portable to the same
architecture.

Now available from specially selected bookshops and darcs repositories.
Please enjoy responsibly!

-- Don


More information about the Haskell-Cafe mailing list