From: Paul Lutus Date: 2006-10-19T16:20:11+09:00 Subject: Re: Performance of ruby hashes unni.tallman wrote: > Anyway to enhance the performance of ruby hashes? My program uses > hashes heavily. Many comments have been offered, but since no one knows what your code looks like, I want to offer the standard advice that assumes you are actually having a hash speed problem. The advice is: Make your hashes smaller by creating two or more tiers of hashes. One way to do this with strings as keys is to create one hash using the first (one, two, whatever) characters as the key for level one, and the remaining characters as the key into the second level. You should be able to figure out how to create a general method that implements this advice. The basic idea is that hash speed degrades as the size of each single-level hash increases, and after a certain size has been reached, breaking the hash into groups (layers if you prefer) improves performance. > So if i could enhance hash performance, or find a > fasster alternative to hashes, i could improve the overall performance > of my program. Gimme some suggestions. Give us the details of the problem -- the nature of the keys, the size of the data set, and so forth. -- Paul Lutus http://www.arachnoid.com