O'Reilly logo

Ruby Under a Microscope by Pat Shaughnessy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. The Hash Table: The Workhorse of Ruby Internals

image with no caption

Ruby stores much of its own internal data in hash tables.

Experiment 5-1: How Long Does It Take to Save a New Instance Variable? showed us how in Ruby 1.9 and 2.0 the ivptr member of the RObject structure pointed to a simple array of instance variable values. We learned that adding a new value was usually very fast but that Ruby was somewhat slower while saving every third or fourth instance variable because it had to allocate a larger array.

Taking a broader look across Ruby’s C source code base, we find that this technique is unusual. Instead, Ruby often uses a data structure called a

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required