develooper Front page | perl.perl5.porters | Postings from August 2021

Re: Robin Hood Hashing for the perl core

Thread Previous | Thread Next
From:
demerphq
Date:
August 26, 2021 16:36
Subject:
Re: Robin Hood Hashing for the perl core
Message ID:
CANgJU+XTGB8P-7aGL+a7ao7Wc-L0tzwpqDHya6c6v3oZfWq4Zg@mail.gmail.com
On Sun, 22 Aug 2021 at 05:40, Ed Avis <ed.avis@qmaw.com> wrote:

> Tony Cook wrote:
>
> >In addition to Nicholas's response, when objects are duplicated into a
> >new thread the duplicated object has a new address which breaks
> >the hash, and finding the object given the address.
>
> But that's equally true with the way hashing works currently.  The address
> changes, so the string representation changes, so you can no longer look up
> with the same key.
>
> % perl -Mthreads -le 'my $x = bless {}; $h{$x} = "hello"; print $h{$x};
> threads->create(sub { print $h{$x} // "undef" })->join'
> hello
> undef
>
> So while it's a reminder to be careful about object identity when you are
> using threads, it's not a point of difference between stringifying hash
> keys and hashing by address.
>

It is a demonstration that we dont have a well defined object identity
function and that having one would be useful. :-)

yves

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About