[erlang-questions] ets vs list

Rapsey <>
Mon Sep 13 15:49:39 CEST 2010


If you need random access and fast traversal, dict and gb_trees are all good
and quite fast options.


Sergej

On Mon, Sep 13, 2010 at 3:45 PM, Jesper Louis Andersen <
> wrote:

> On Mon, Sep 13, 2010 at 2:58 PM, Max Lapshin <>
> wrote:
>
> > and it seems, that my choice was wrong:
> >
>
> In addition to the comments of Ulf: When you run the ets:select/2
> call, you are copying all of the ETS table into the memory space of
> the process and then operate on it. You don't need that for the List
> case since the memory is already in the heap of the process (Line 47).
> Line 48 can be merged with the match-spec in Line 46 so you avoid to
> create yet another list. This will also mean you (at least in theory)
> copy less data.
>
> In Haskell, you can rely on the optimizer to fuse several traversals
> of a list into a single run over the list. This is not the case for
> strict/eager languages, so you need to optimize list access to only
> run a single pass.
>
> --
> J.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list