[plt-scheme] Regarding symbols

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun May 16 09:25:13 EDT 2004

At Sun, 16 May 2004 11:35:51 +0200, Øyvin Halfdan Thuv wrote:
> > > - can I use strings as keys in the hash-table, or is it better
> > > (faster) to use symbols (e.g. by using string->symbol). There are
> > > quite a few words, say 20000-40000 depending on the language.
> > 
> > I will let Matthew Flatt answer that one.
> Well, thinking about this, when using symbols as keys, I suppose I'm
> actually dealing with adresses and not some computed value. 

Essentially, yes.

If you start with a string key for each lookup, then using a
string-keyed 'equal hash table is likely faster than converting each
string to a symbol.

If you use the same key multiple times, then it might be worth
converting the key string to a symbol, so that the string's hash code
is effectively computed just once.


Posted on the users mailing list.