Re: [OT] Re: [performance/benchmark] printing techniques
On Thu, 8 Jun 2000, Perrin Harkins wrote: On Thu, 8 Jun 2000, Matt Sergeant wrote: The one that bugs me is when I see people doing this: $hash{"$key"} instead of this: $hash{$key} Those two now also result in the same code. ;-) But the former is just ugly. Sometimes it's worse than just ugly. See the entry in the Perl FAQ: http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#What_s_wrong_with_always_quoting Not likely that anyone would be using something as a hash key that would suffer from being stringified, but possible. It's definitely a bit slower as well, but that's below the noise level. It's not slower in 5.6. "$x and $y" in 5.6 gets turned into $x . ' and ' . $y (in perl bytecode terms). -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
Re: [OT] Re: [performance/benchmark] printing techniques
It's not slower in 5.6. "$x and $y" in 5.6 gets turned into $x . ' and ' . $y (in perl bytecode terms). that's not new to 5.6.0, variable interpolation in ""'s has always turned into a concat tree, though 5.005_03 is the oldest version i have handy to check with. and, this "$feature" can be quite expensive.
Re: [OT] Re: [performance/benchmark] printing techniques
On Wed, 7 Jun 2000, Perrin Harkins wrote: On Wed, 7 Jun 2000, Matt Sergeant wrote: On Wed, 7 Jun 2000, Eric Cholet wrote: This said, i hurry back to s/"constant strings"/'constant strings'/g; Those two are equal. Yes, although it's counter-intutive there's no real performance hit from double-quoting constant strings. The one that bugs me is when I see people doing this: $hash{"$key"} instead of this: $hash{$key} Those two now also result in the same code. ;-) But the former is just ugly. -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
Re: [OT] Re: [performance/benchmark] printing techniques
On Thu, 8 Jun 2000, Matt Sergeant wrote: The one that bugs me is when I see people doing this: $hash{"$key"} instead of this: $hash{$key} Those two now also result in the same code. ;-) But the former is just ugly. Sometimes it's worse than just ugly. See the entry in the Perl FAQ: http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#What_s_wrong_with_always_quoting Not likely that anyone would be using something as a hash key that would suffer from being stringified, but possible. It's definitely a bit slower as well, but that's below the noise level. - Perrin
Re: [OT] Re: [performance/benchmark] printing techniques
Sometimes it's worse than just ugly. See the entry in the Perl FAQ: http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#What_s_wrong_with_ always_quoting Not likely that anyone would be using something as a hash key that would suffer from being stringified, but possible. It's definitely a bit slower as well, but that's below the noise level. Actually, when you use a reference as a hash key, it is automatically stringified anyway. http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#How_can_I_use_a_re ference_as_a_h So that means that: $hash{"$key"} and $hash{$key}differ only in the relative merits of their beauty. :) Mike Lambert
[OT] Re: [performance/benchmark] printing techniques
On Wed, 7 Jun 2000, Matt Sergeant wrote: On Wed, 7 Jun 2000, Eric Cholet wrote: This said, i hurry back to s/"constant strings"/'constant strings'/g; Those two are equal. Yes, although it's counter-intutive there's no real performance hit from double-quoting constant strings. The one that bugs me is when I see people doing this: $hash{"$key"} instead of this: $hash{$key} That one is actually in the perlfaq man page, but I still see it all the time. The performance difference is very small but it does exist, and you can get unintended results from stringifying some things. - Perrin