returning to cost of Integer

John Meacham john at repetae.net
Tue Aug 1 12:21:42 EDT 2006


On Tue, Aug 01, 2006 at 02:57:31PM +0400, Bulat Ziganshin wrote:
> John, Integer values in many cases used just to keep small numbers
> which can be larger than 2^32 (2^64) in rare cases. For example,
> "type FileSize = Integer" used in IO library. so it's important to
> keep operations on small Integers fast and use minimum amount of
> memory
> 
> how about:
> 
> data Integer = S# Int# | L# !(ForeignPtr MPZ)

That is more or less what it is now. The point was that turning it into
a product type (one with only a single constructor) would open it to the
various unboxing optimizations, potentially being a bigger win than
treating small integers specially.

It would be interesting to speed test some straight FFI bindings to gmp
and the various other bignum libraries out there

http://www.csc.fi/math_topics/Mail/FAQ/msg00015.html


        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Glasgow-haskell-users mailing list