On 3/29/06, Yuval Kogman <nothingmuch@woobling.org> wrote: > On Wed, Mar 29, 2006 at 13:05:49 +0200, demerphq wrote: > > > Well i know from experience on other matters that using StrVal for > > indexing reference lookups is massively slower than using refaddr. I > > just whipped up a benchmark and it shows that refaddr is an order of > > magnitude faster than than StrVal. And IMO if you are already dealing > > with a piggish interface (ie a tied hash) then you aught to careful > > about trimming unnecessary fat elsewhere. > > Okay, i'm sold... > > I'll write a quick patch later today when I'm back home unless > someone beats me to it. Cool. There is an additional benefit to using refaddr(): it is not susceptible to reblessing. If you are keying on the results of StrVal then dont you have an issue when the object is reblessed? D:\Dev\Jonas>perl -le"$x=bless {},'foo'; print $x; bless $x,'bar'; print $x;" foo=HASH(0x225730) bar=HASH(0x225730) The way this is normally dealt with is you split off the classname from the string, which is even *more* work. But with refaddr theres no need: D:\Dev\Jonas>perl -le"use Scalar::Util qw(refaddr); $x=bless {},'foo'; print refaddr $x; bless $x,'bar'; print refaddr $x;" 2250592 2250592 Cheers, yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next