Get the latest tech news
Fast Allocations in Ruby 3.5
Many Ruby applications allocate objects. What if we could make allocating objects six times faster? We can! Read on to learn more!
If we run the above program with Ruby 3.4.2, we’ll see that the test method allocates 2 objects: and instance of Foo, and a hash for passing the keyword parameters to the C implementation of Class#new. Unfortunately I found that using... was quite expensive because at the time, it was syntactic sugar for*, **, &, and Ruby would allocate extra objects to represent these splat parameters. It’s very rare for code to allocate exactly the same type of object many times in a row, so the class of the instance local variable will change quite frequently.
Or read this on Hacker News