Fwd: [Haskell-cafe] Data.Binary suboptimal instance
alexey.skladnoy at gmail.com
Sat May 23 12:58:42 EDT 2009
On Saturday 23 May 2009 02:55:17 Antoine Latter wrote:
> Or you could go for the compromise position, where the list can be
> part of a complex data structure so you're not relying on EOF to find
> the end.
Interesting solution however it does not perform very nice. I wrote
> xs :: [Word32]
> xs = [1..(10^6)]
Writing chunked list of Word32
> B.writeFile "chunked" . toLazyByteString . putList putWord32be $ xs
Reading chunked list of Word32
> print . last . runGet (getList getWord32be) =<< B.readFile "chunked"
Writing stream of Word32
> B.writeFile "stream" . encodeStream $ xs
Reading stream of Word32
> print . (last :: [Word32] -> Word32) . decodeStream =<< B.readFile "stream"
I didn'd do any profiling so I have no idea why writing is so slow.
Best regard Khudyakov Alexey
More information about the Haskell-Cafe