The upcoming Ruby 2.0 release contains an interesting performance optimization you may not have heard of before: small Hashes are actually implemented as Arrays!
In this micro talk, I'll:
- review the basic theory behind hash functions and hash tables,
- show you the new internal data structures that Ruby 2.0 uses to save keys and values, and
- present some performance data that proves this optimization exists and how much time it will actually save you.
Do you really need to know how Ruby works internally to be a Ruby devloper? Probably not. But looking "under the hood" is a lot of fun, and someday might help you use the language more competently.
Pat Shaughnessy is a Ruby developer working at a global management consulting firm. Pat also writes a blog about Ruby development at http://patshaughnessy.net, and is working on an eBook about Ruby Internals. Pat's articles and presentations have been featured multiple times on the Ruby Weekly newsletter, the Ruby5 podcast and the Ruby Show. When he's not at the keyword, Pat enjoys spending time with his wife and two kids. Pat is also a fluent Spanish speaker and travels frequently to Spain to visit his wife's family.