From: Alex Gutteridge Date: 2007-04-03T09:50:46+09:00 Subject: Re: implementing an array based class On 3 Apr 2007, at 08:35, bwv549 wrote: > Some of the data I deal with involves hundreds of thousands of records > where each is very predictable in the number of attributes. By going > from a hash based object to an array based object I am able to > substantially decrease memory usage. However, the array based object > I have made (see below), is really lame for two reasons: > > 1. It is a pain to make a different array based class > 2. When I call 'flatten' on an array of these objects, my objects get > flattened, too (how do I prevent this?) > > I realize that I could just use arrays of arrays for all the objects, > but for ease of programming I'd like to be able to access an object's > attributes by name. Does anyone know of some memory efficient and > fast way of doing this (that's insensitive to 'flatten')? snip > Ideas and suggestions are most welcome. Thanks. I don't know about speed/memory use, but perhaps Struct (in stdlib) or Arrayfields: http://raa.ruby-lang.org/project/arrayfields/ does what you want? Alex Gutteridge Bioinformatics Center Kyoto University