[ruby-core:94329] [Ruby master Feature#15955] UnboundMethod#apply
From:
ruby-lang-bugs@...
Date:
2019-08-13 21:27:40 UTC
List:
ruby-core #94329
Issue #15955 has been updated by darkdimius (Dmitry Petrashko). > I wonder that people use this pattern! (I'd never used it except test). This pattern currently represents substantial fraction of allocations that Sorbet runtime does, so building a way to not allocate in this pattern might have a sizeable impact in reducing the overhead of runtime type checking. ---------------------------------------- Feature #15955: UnboundMethod#apply https://bugs.ruby-lang.org/issues/15955#change-80717 * Author: nelhage (Nelson Elhage) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- 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 `UnboundMethod`s in some hot paths in my application due to our metaprogramming idioms, and the allocation from `.bind` is comparatively expensive. I'd love `unbound_method.apply(obj, args…)` to be equivalent to `unbound_method.bind(obj).call(args…)` but without allocating the intermediate `Method` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>