On Tue, Dec 31, 2013 at 6:09 PM, Carlo E. Prelz <fluido / fluido.as> wrote:
>         Subject: Re: Byte Arrays in Ruby
>         Date: mar 31 dic 13 06:04:05 +0100
>
> Quoting Carlo E. Prelz (fluido / fluido.as):
>
>> Maybe there is something that helps in that direction, but from what I
>> know, since in Ruby everything is an object, even if you were to limit
>> the disk occupation of the actual variable to one byte, it would then
>> need all the management infrastructure that each other object
>> requires. Thus, I think you would not save so much.
>
> Oops. I had not noticed that you'd like to use those data as
> booleans.  In Ruby, booleans are already quite optimized memory-wise.
>
> The saving is even less in this case.

Actually no.  If you need, say, 120 boolean flags you can store them
in 15 bytes (120 bits / 8 bits per byte).  If you have a Ruby Array
with 120 entries you need 120 times the size of a single pointer (IIRC
4 bytes = 32 bit on a 32 bit Ruby).  That makes 120*4 = 480 bytes.

Kind regards

robert

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