Chapter 7. The Hash Table: The Workhorse of Ruby Internals
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