# \[Ruby 1.9-Feature#3917\]\[Open\] \[proposal\] called\_from() which is much faster than caller()

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-feature-3917-open-proposal-called-from-which-is-much-faster-than-caller/196335>\
**Category:** Development\
**Created:** [October 12, 2010, 1:41am UTC](https://www.ruby-forum.com/t/ruby-1-9-feature-3917-open-proposal-called-from-which-is-much-faster-than-caller/196335 "2010-10-12T01:41:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makoto\_kuwata](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@makoto\_kuwata](https://www.ruby-forum.com/u/makoto_kuwata)\
**Post date:** [October 12, 2010, 1:41am UTC](https://www.ruby-forum.com/t/ruby-1-9-feature-3917-open-proposal-called-from-which-is-much-faster-than-caller/196335/1 "2010-10-12T01:41:59Z")

</div>

Feature #3917: [proposal] called\_from() which is much faster than  
caller()  
[http://redmine.ruby-lang.org/issues/show/3917](http://redmine.ruby-lang.org/issues/show/3917)

$B5/I\<\<T(B: makoto kuwata  
$B%9%F!\<%?%9(B: Open, $BM%@john(B: Normal  
$B%+%F%4%j(B: core, Target version: 1.9.x

I propose to introduce Kernel#called\_from() which is similar to caller()  
but much faster than it.

## Background

There are some cases to want to know from where current method is  
called.  
In this case, Kernel#caller() is used.

But Kernel#caller() has performance issues for these cases.

- caller() retrieves entire stack frame. It is too heavy.
- caller() returns an array of “filename:linenum in `method’” string.  
User must parse it and retrieve filename and linenum by rexp.  
It is also very heavy weight task.

Therefore I propose Kernel#called\_from() which is very light weight  
compared to caller(). A certain benchmark shows that called\_from()  
is more than 20 times faster tan caller().

$B8
