Title: RE: Very[OT]:Technical query re: scratchpad lookups for my() vars

From: Paul [mailto:[EMAIL PROTECTED]]
>
> Anybody know offhand *why* my() lexicals are supposedly faster?

Because a dynamic variable allocates a "new" value at runtime which occludes the global value until it's scope expires. In contrast, a lexical variable is unique to its code value's (CV) context which was determined at parse time. However, if you recursively call that CV, then Perl has to allocate a new value for the lexical.

Urban legend says that lexicals are on average 10% faster than dynamic variables. I wonder if that is true... and what difference recursion makes. I wonder how you'd write a script to benchmark that and actually benchmark the right thing...

Reply via email to