returning to cost of Integer

John Meacham john at
Mon Jul 31 21:19:37 EDT 2006

> >However because Int is often unboxable where as Integer is never
> >unboxable there are certainly programs where the factor is much much
> >greater than x2 or x3. If the Int can be unboxed into an Int# then the
> >operations are very quick indeed as they are simple machine  
> >primitives.

This has made me wonder whether we are better off getting rid of the
small integer optimization and turning Integer into a straight
unboxable ForeignPtr to a GMP number. this would also mean we could use
the standard GMP that comes with the system since ForeignPtr will take
care of GCing Integers itself. This was my plan with jhc, but at the
moment, Integer is still just intmax_t.

Another option would be to keep the small integer optimization but make
it CPR

data Integer = Integer Int# !(Ptr MPZ)

where if the Ptr is NULL then the Int# contains the value...


John Meacham - ⑆⑆john⑈

More information about the Glasgow-haskell-users mailing list