On Tue, 3 Apr 2007, bwv549 wrote:

> MEMORY:
> Arrays take about 20 times less memory than structs or MyObject.
> MyObject uses a little less memory than a struct, but it depends on
> how the initialization is implemented.  Normal objects (in this
> experiment, mileage will vary I think) took a little more than twice
> as much memory as Structs or MyObject.
>
> I didn't test ArrayFields (even though it looks like a very useful
> class) based on my understanding that each array that is created must
> then be set with the fields that it will use (which seems like it
> would be too much overhead for what I'm doing, although I could be
> wrong).

arrayfields was specifically design for the case you're coding.  in particular
it was designed to provide fast keyword access and low memory overhead - i was
using it with huge postgresql result sets which were arrays.  as you point
out, arrays use far less memory that any other solution.  they are also much
nicer to work with

   csv = tuple.join ','

for example.  anyhow, the @fields object is not copied for each array - only a
reference is held.  so if one does this

   fields = %w( a b c )

   huge_number_tuples.each{|tuple| tuple.fields = fields}

then ALL tuples share the fields object - a copy is not taken.  anyhow, i'd
love to see your tests using it.

regards.


-a
-- 
be kind whenever possible... it is always possible.
- the dalai lama