Iaki Baz Castillo wrote: > El Jueves 02 Abril 2009, Tony Arcieri escribi: > >> Use symbols... FOR SPEED! Unfortunately that speed comes at a price... >> you >> really want to globally internalize arbitrary input? Symbols are >> effectively a freeform enumeration... the reason you're running into >> problems is because you're trying to enumerate arbitrary inputs. > > Yes. It's a parser so custom headers could arrive. I want to store them in > a hash like: > > headers = { :from => "alice@qweeq", ":to => "bob@qweqwe } I'd figure out what very common headers are and make them freezed constants, like: FROM = "From".freeze TO = "To".freeze and put references to those string "constants" as keys into the Hash. I assume that this will be as fast as symbols when accessing the hash with those constants, as equality testing just needs to tests for object identity (object_id) and not for the equality of the content. headers = {} headers[FROM] = "alice@qweeq" headers[TO] = "bob@qweqwe" ... p headers[TO] p headers["To"] # works as well, but should be slower Would you like to benchmark this against using symbols? Btw, this is the approach that for example Mongrel uses. Regards, Michael