On 12.11.2009 21:24, Caleb Clausen wrote:
> On 11/9/09, Ralph Shnelvar <ralphs / dos32.com> wrote:
>> Newbie here:
>>
>> I will want/need to create an array of approximately 300K rows and 20
>> columns. The array will be an array of either 32-bit quantities or 64-bit
>> quantities.
>>
>> Does Ruby support native 64-bit quantities?
>>
>> What's a good/best way to to create such an array. Is there a way to
>> tell Ruby, "OK, I'm done with this array."
>>
>> Can one create such an array such that the garbage collector can
>> free the memory in one fast operation?
> 
> I'm surprised that no-one has yet mentioned narray; I'd think it's the
> ideal data structure for this kind of problem. (I've never used it,
> tho.)

Actually everybody waited for you to finally come up with your reply. 
Shame on you that it took you so long.  ;-)

> I'd like to point out that while the memory cost of a Fixnum is small
> (4 or 8 bytes), the memory cost of a Bignum is considerably larger....
> something like 32 bytes or so, even if it's only storing a 64bit
> value. If you expect a significant number of Bignums to be stored in
> this array, you should be aware of this. Yet another reason to
> consider narray, to my mind.

Certainly.  However, if Bignums work as well, why worry to use another 
lib?  Whether the allocation overhead is OK or not depends of course on 
the use case.  Btw, did we see a more concrete description of the 
problem?  I cannot remember having seen it.

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/