seniorRuby
How does Ruby optimize method calls using polymorphic inline caches (PIC)?
Updated May 17, 2026
Short answer
PIC stores multiple class-method mappings at a call site to speed up dynamic dispatch.
Deep explanation
When a method call site sees multiple receiver types, Ruby evolves from monomorphic inline cache (single type fast path) to polymorphic inline cache (multiple cached entries). Each entry maps a receiver class to a resolved method pointer. This avoids full method lookup across inheritance chains.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro