Project

General

Profile

Actions

Feature #11745

closed

saving bits

Added by eike.rb (Eike Dierks) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:71699]

Description

Hi at the ruby team,

Sometimes we are still working with bits: these yes/no things.
But even a bit is an object, this is ruby!

I'm not even sure how bits are save in mri,
I believe they are all objects (which is good)

I believe they should be fly weights,
and we should save bits one by one,
instead of wasting a full full object for every bit.
(sorry if it already works this way)

I'd like to sugest an optimization for the mri,
that a boolean object should be saved in one bit.
This obviously needs a lot of changes underneath.
(which might not be worth it in the end)

I coming from this rails stuff.
who cares about the bits ...
we're spendig gigs of ram anyway.

but then again, thinking of the bit.
I sometimes feel like saving a bit should take less memory.

I could imagine to make a special rule for bit objects,
to save them more efficiently.

(please look this up at smalltalk, they did it there as well)

Updated by naruse (Yui NARUSE) over 8 years ago

Keep a string and store/manipulate those bits in it.

Updated by matz (Yukihiro Matsumoto) over 8 years ago

  • Status changed from Open to Closed

Eike, we have done that kind of optimization for decades.

Matz.

Updated by mame (Yusuke Endoh) over 8 years ago

Yui NARUSE wrote:

Keep a string and store/manipulate those bits in it.

I also recommend to use Bignum if you don't have to change the table frequently.
Bignum#[] is really useful for the use case.

--
Yusuke Endoh

Updated by Hanmac (Hans Mackowiak) over 8 years ago

dam i wanted to make a request to add a #[]= method similar to the #[] one, until i noticed that Bignum like others are fixed, so thats not so easily possible ...

but you can wrote a wrapper class that does have #[] and #[]= and store the bigflag data in a Bignum.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0