The values for true and nil were respectively 2, 4 in 1.9.3 and 1.8.7,
but have been changed to 20, 8 in ruby2.0.0 - even though the id of
false remains the same i.e. 0 and the ids for Fixnum maintains the same
old 2n+1 pattern.
What's the reason behind this object_id change?
Why was this change made? How is this going to help developers?
your question was already answered at stackoverflow:
Seems to be something to do with “flonums” – a technique for speeding up
floating point calculations on 64-bit:
github.com/ruby/ruby/blob/v2_0_0_0/include/ruby/ruby.h#L383-431 and
ruby-forum.com/topic/4404164.
I have tried to read it, but the presentations given in that link are
written in Japanese, and I couldn't understand what Flonums are why they
are implemented.
Know any place where I can read them in English to understand why it was
changed?
Because immediate values have no overhead. It takes memory and cpu cycles
to create an object instance; it takes no (extra) memory if the value is
stored in the reference (ie the object id _is_ the value, albeit slightly
modified), and far fewer cycles to shift and OR some bits.
ruby-forum.com/topic/4404164 specifically states why it was changed. Its a speed thing.
···
Bharadwaj Srigiriraju <mailto:lists@ruby-forum.com>
March 20, 2013 10:10 AM
I have tried to read it, but the presentations given in that link are
written in Japanese, and I couldn't understand what Flonums are why they
are implemented.
Know any place where I can read them in English to understand why it was
changed?
Hans Mackowiak <mailto:lists@ruby-forum.com>
March 20, 2013 2:03 AM
floating point calculations on 64-bit:
github.com/ruby/ruby/blob/v2_0_0_0/include/ruby/ruby.h#L383-431 and
ruby-forum.com/topic/4404164.
--
D. Deryl Downey
"The bug which you would fright me with I seek" - William Shakespeare - The Winter's Tale, Act III, Scene II - A court of Justice.
I'm interested (as is Hans, I think) in understanding the specifics of
the implementation and _why_ this leads to better performance. Looks
like someone would have to translate the Japanese, though.
···
On 20 March 2013 14:27, D. Deryl Downey <me@daviddwdowney.com> wrote:
ruby-forum.com/topic/4404164 specifically states why it was changed. Its a speed thing.