[erlang-questions] How do things like module dict impleented to work fast?

Robert Virding <>
Fri Apr 24 09:27:39 CEST 2009


There is no trick as such, as you saw dict is written in normal erlang.
Although some effort has been made to ensure that as much as possible of the
"old" dict is reused without copying, only the bits which contain new data
are actually created new. One way of doing this is to break up the big table
into a tree of smaller bits. There are a few other small tricks which help
to improve garbage collection, but they are still all normal erlang.

Gb_trees and array use the same techniques of building trees so that only
small bits need to be rebuilt.

Robert

2009/4/24 Dmitry Kakurin <>

> Newbie question.
> When I append something to a dictionary a new copy is returned and the
> old copy is still valid (the functional nature of Erlang).
> I've assumed that there is some kind of clever trick to create an
> appearance of copy without actual data duplication.
> However after looking at dict sources it looks like it does a simple copy.
> Am I missing something or there is no trick?
>
> - Dmitry
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090424/d7e17b7e/attachment.html>


More information about the erlang-questions mailing list