I'd love a way to apply an UnboundMethod to a receiver and list of args without having to first
bind it. I've ended up using
UnboundMethods in some hot paths in my application due to our metaprogramming idioms, and the allocation from
.bind is comparatively expensive.
unbound_method.apply(obj, args…) to be equivalent to
unbound_method.bind(obj).call(args…) but without allocating the intermediate
Updated by Eregon (Benoit Daloze) 23 days ago
Escape analysis might be able to remove the Method allocation of
In fact, TruffleRuby does it for such a pattern.
So the interesting question for me is whether this should be fixed by the JIT or by a new method.
Could you share a benchmark representing your usage?