From: Joel VanderWerf Date: 2009-07-14T04:26:51+09:00 Subject: Re: Performance question Pito Salas wrote: > I have a scenario where I will be storing thousands of objects in an > array. Each one will have, say, two attributes, name and age. Some of > them may have other attributes in addition. > > Note: I don't need to have any methods, inheritance or any other > 'class-ish' behavior. Just the data. > > Here are three representations. Which one will be faster? Which one will > be smaller? Probably the hash representation, but what about an array of [ [name, age], ...] Can't beat that for fast access, and storing a fixnum (age) in an array is particularly space-efficient (only 4 bytes for this field, per entry). Another option is the arrayfields gem, if you want array storage but keyword interface. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407