returning to cost of Integer
simonpj at microsoft.com
Tue Aug 1 03:02:26 EDT 2006
If there was an alternative small/big rep, no matter how encoded, it'd still entail conditionals (2 for addition say) to check for that path. And the conditionals also hurt optimisations.
But both possibilities would be an interesting thing to try.
| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-users-bounces at haskell.org]
| On Behalf Of John Meacham
| Sent: 01 August 2006 02:20
| To: glasgow-haskell-users at haskell.org
| Subject: Re: returning to cost of Integer
| > >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 - ⑆repetae.net⑆john⑈
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
More information about the Glasgow-haskell-users