From: "charliesome (Charlie Somerville)" Date: 2013-11-05T08:06:38+09:00 Subject: [ruby-core:58161] [ruby-trunk - Bug #9079] Interpolated Symbol creates unnecessary intermediate String on the heap Issue #9079 has been updated by charliesome (Charlie Somerville). To shed a bit of light on why this happens, it turns out :"" syntax is just sugar for "".intern: ~ trunk �� ruby --dump=insns -e ':"hello #{123}"' == disasm: @-e>====================== 0000 trace 1 ( 1) 0002 putobject "hello " 0004 putobject 123 0006 tostring 0007 concatstrings 2 0009 opt_send_simple 0011 leave ---------------------------------------- Bug #9079: Interpolated Symbol creates unnecessary intermediate String on the heap https://bugs.ruby-lang.org/issues/9079#change-42747 Author: wycats (Yehuda Katz) Status: Open Priority: Normal Assignee: ko1 (Koichi Sasada) Category: Target version: ruby -v: ruby 2.0.0p343 (2013-10-31) [x86_64-linux] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN This case: x = "world" y = :"hello#{world}!" allocates one T_STRING according to ObjectSpace.count_objects. Since all of the concatenation happens as part of the symbol generation, it shouldn't be necessary to create a Ruby string. -- http://bugs.ruby-lang.org/