Erlang Efficiency quesitons

Alexander Williams <>
Wed Mar 14 23:45:29 CET 2001


On Wed, Mar 14, 2001 at 05:38:59PM +0000, Francesco Cesarini wrote:
> * Use binaries when shuffling around large amounts of data between
> processes.
> * Some one on the list had mentioned that appending binaries results in
> them being copied, thus avoid it.

You know, I'm wondering why no one's suggested before (and I suppose
I'm suggesting now) why the underlying representation of strings
hasn't been changed to Binaries instead of Lists (or at least
discussion thereof).  If the functions in string: were changed, that'd
be 80% of the tweaking necessary right there.  One can already do
pattern-matching on Binaries, so you don't lose much there.

>From an efficency PoV, the main drawback would seem to be that
Binaries copy when appended, but going to a different programming
pattern that involves building lists of Binary-strings and then
joining them should be able to get around that problem; Python's
strings are "immutable," much as Binaries seem to be, and so share the
quality of being copied to create a new entity when +'d, but if one
constructs a List of strings, calling string.join() on the List will
return a single string without much overhead.

Thoughts?

-- 
Alexander Williams ()               | In the End,
  "Blue Jester needs food."                             | Oblivion
  "Blue Jester needs fuku-wearing cuties."              | Always
  http://www.chancel.org                                | Wins



More information about the erlang-questions mailing list