Y
Hacker News
new
|
ask
|
show
|
jobs
by
rnicholson
5728 days ago
Why is
attr_reader :foo
faster than
def foo;@foo;end
Is this in 1.9.x? or 1.8.x? or both?
1 comments
texel
5728 days ago
Courtesy of Evan Phoenix... apparently in MRI, attr_reader doesn't create a method, instead creating a NODE_IVAR in the method table of the class. This circumvents method creation/invocation overhead and is therefore faster.
link