[erlang-questions] ets vs list
Jesper Louis Andersen
Mon Sep 13 15:45:47 CEST 2010
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.
More information about the erlang-questions