list BIFs

Ulf Wiger ulf.wiger@REDACTED
Mon Dec 7 16:40:58 CET 2009


(I guess I should fork the git repos and do this myself, but then it 
won't happen this year...)

I think it is quite appropriate that the following
lists functions are implemented in C:

lists:member/2
lists:reverse/2
lists:keymember/3
lists:keysearch/3
lists:keyfind/3

(append and subtract are also BIFs, of course)

I think the list should be extended with the following:

lists:keydelete/3
lists:keyreplace/4
lists:keystore/4

I did some benchmarking recently, comparing the
use of a plain key-value list with that of dict.
The plain list was quite competitive for read
access up to a fairly large number of elements
(depending on the ratio of building the list and
accessing the elements, the list is competitive
even for data sets of > 200 elements.) Since only
the lookup functions are optimized, it gets trickier
to judge when updates are involved as well.

Making C implementations of the above functions is
trivial, at least relatively speaking.

I feel convinced that optimizing the most popular
list update functions (perhaps also the basic
lists:sort/1) would do much to speed up existing
programs, and also extend the reach of straightforward
list programming - a good thing IMHO.

BR,
Ulf W

-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com


More information about the erlang-questions mailing list