On Tue, 24 May 2011 10:42:34 +0200, Johan Tibell wrote:
Hi Daniel,

On Tue, May 24, 2011 at 10:07 AM, Daniel Díaz
<danield...@asofilak.es> wrote:
Hi, cafe,

I just feel curiosity. In the bytestring package, Data.ByteString module, functions like length, index, and others with Int in its type signature, have Int64 in the analogous Data.ByteString.Lazy version. What is the
reason?

A strict ByteString is one contiguous chunk of memory so it cannot be
longer than an Int (if we assume and Int is either 32 or 64 bits for a
second). However, a lazily generated stream can be much bigger than
main memory, so it makes sense to use a bigger type to refer to e.g.
it length. Now, you might say that lazy ByteString should use Integer
instead of Int64. However, Int64 performs much better so I think the
loss of generality is worth it.

Johan

Thanks, it makes sense.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to