in reply to Does the size of a variable's name affect memory?
Hm, none of the answers so far have gone into detail pedantically enough for me tonight. Here's an gutsier explanation that is mostly true.
It depends on whether that's a global variable or a lexical variable. Perl doesn't optimize away any used variable names completely, but it does only store a single copy of lexical variable names in the appropriate lexical pad. All lexical variable accesses involve indexed lookups into the appropriate lexical value pad.
Global symbols are different, and the appropriate op in the optree keeps around the name of the symbol for a runtime lookup. That means if you refer to a global variable three times in your program, you'll have at least three more copies of its name in memory.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Does the size of a variable's name affect memory?
by Anonymous Monk on Feb 17, 2005 at 09:23 UTC | |
|
Re^2: Does the size of a variable's name affect memory?
by hv (Prior) on Feb 17, 2005 at 13:22 UTC |