efficiency question
Hal Daume III
hdaume@ISI.EDU
Sun, 10 Feb 2002 18:10:23 -0800 (PST)
I don't know of a reference, but here's the basic idea:
if you have a polymorphic type (like [a]), and it's instantiated to [Int]
(or whatever), instead of storing in memory a standard linked list
representation like
[1,2] = 1:2:[] =
[1 x] /--> [2 x] /--> Nil
\---/ \---/
(which would be standard), it stores it as:
[x x] /--> [x x] /--> Nil
| \---/ | \---/
1 2
So instaed of storing 1 and 2 in the list, it stores pointers to
them. The reason it does this is so that it makes it easy to generate
code for polymorhpic functions. (,) being boxed means that instead of
storing a pair of element, you're storing a pair of pointers. That means
you get worse performance because you have to chase more pointers.
(at least that's my impression)
- hal
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
On Sun, 10 Feb 2002, Jorge Adriano wrote:
> On Sunday 10 February 2002 18:48, Kirsten Chevalier wrote:
> > I'd guess that it's not just that you have to apply the (,) constructor --
> > it also has to do with the fact that the tuples it's constructing here are
> > boxed.
>
> could you elaborate a little more on that (boxed / unboxed) or provide a link
> on the subject?
>
> thanks
> J.A.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>