Re:Why Python is Slow: Looking Under the Hood
by dragonwriter on Friday May 09, 2014 @02:21PM
(#7722468)
Ruby -- or more precisely, MRI, though some other interpretations may do something similar -- uses the a fixed set of object_ids (which is what is stored on the stack to locate an object on the heap) for small integers, so if the object_id is within that range, the interpreter uses it directly to calculate the value, and doesn't need to go to the heap to get a value. (MRI does a similar thing with the values nil, true, and false, as well.)
[ Parent
| on HN ]
Re:Why Python is Slow: Looking Under the Hood
by ForHackernews on Friday May 09, 2014 @04:16PM
(#7723040)
Python does the same thing for integers in the range (-5, 256)