[erlang-questions] Performance of matches

Darren New <>
Mon Jun 2 23:15:02 CEST 2008


Darren New wrote:
> David Lloyd wrote:
>  >> Is either of those O(1) lookup time?
>  > It strikes me that this is something that is eminently easy to profile...
> 
> Good point. 

Actually, I was asking a slightly more complex question. It's only easy 
to profile if the compiler doesn't have special cases that make some 
things faster. For example, Haskell has enough smarts to notice some 
operations never look at the unmodified value after you modify it, and 
use that to avoid copying the whole collection (for example) when you 
modify one element. Much the same way I've read Erlang avoids copying 
binaries when you append to them in certain circumstances.

So, basically, I was trying to ask the question "is there any O(1) data 
structure in Erlang, such as a hashtable or an array equivalent?" Maybe 
it just hasn't clicked for me, is all.

Good to know the process dictionary is actually a hashtable, but there's 
only one per process and they don't nest, so that's pretty limited. Plus 
there are recommendations to avoid it, for some reason that isn't 
explained.

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."



More information about the erlang-questions mailing list