From: ara.t.howard@... Date: 2005-12-29T12:10:56+09:00 Subject: Re: What is the difference between :foo and "foo" ? On Thu, 29 Dec 2005, Johannes Friestad wrote: > On 12/28/05, ara.t.howard@noaa.gov wrote: >> On Thu, 29 Dec 2005, Johannes Friestad wrote: >> >> >>> Symbols are (or can be) quicker for hash lookup, since it is sufficient to >>> compare object identity to find whether two symbols are the same, while >>> strings must be compared character by character. You are unlikely to notice >>> the difference unless your program uses hashes heavily. >> >> i see this claim all the time but never data supporting it, all my test >> programs have shown the opposite to be true. >> > > Along with Jim and Mauricio, my tests indicate that symbols are > consistently quicker, even on short strings. that way well be true now. however, if you look at my test it goes to some lengths to make the test a little more 'real-world': - creats a large (2 ** 13) hash - poplate using a semi-random distribution - selects keys for lookup in a semi-random distribution - fork for each test to isolate tests somewhat - disable GC for each test - runs each test 4 times in anycase, all i'm driving at is that a pretty heavy duty test (not saying mine is that test) is required to eliminate the differences data distribution, gc, and system load have on the results. in particular i can see how a linear distribution might have a huge effect - seeing as symbols are essentially numbers and hash more predictably whereas making the jump from '9999' to '10000' is likely to land in quite a different bucket. it's nonetheless very interesting to see some tests though. i use both btw. ;-) -a -- =============================================================================== | ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================