Subject: Re: [erlang-questions] Internal compiler atoms

Anthony Ramine writes:
> > Le 28 juil. 2017 à 08:43, Albin Stigö <[email protected]> a écrit :
> >
> > 4. If you really DO need to create dynamic atoms for a quick and dirty
> > hack, keep in mind that atoms with a common prefix ie. foo_1, foo_2,
> > foo_3 etc will lead worse performance because of how erlang compares
> > atoms (some Erlang guru correct me if I'm wrong but this used to be
> > the case).
> Wrong, atom comparison is always O(1).

Equality/inequality tests on atoms is O(1). (That's the whole point of atoms,
and their analogues in LISP, i.e. "symbols".)

Comparisons (<, >, etc) is O(length(atom_to_list(Atom)), and with
common prefixes the cost is indeed higher.

C.f. erts/emulator/beam/utils.c:erts_cmp_atoms().
erlang-questions mailing list
[email protected]


Programming list archiving by: Enterprise Git Hosting