Garrett Goebel wrote:
> 
> 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...

Yes this is OT, but I'll contribute to the problem as well...

My coworker Gisle Aas (maybe you've heard of him ;) says that globals
and lexicals have identical speed because Perl optimizes out the
symbol-table lookup.

Trust Gisle.

-- 
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'

Reply via email to