http://www.perlmonks.org?node_id=760475


in reply to Re^8: elsif chain vs. dispatch
in thread elsif chain vs. dispatch

Yes, if I understand your point correctly: There is no absolute guarantee that all keys won't hash to the same hash key until the keys are absolutely unique! Correct!
You understood me utterly wrong. The claim was made Perl detects if too many keys hash to the same bucket, the hash is expanded in size and the keys reinserted, spreading over more buckets. I then pointed out that the description of how it's done still means that you can have enough keys map to the same bucket so your lookup isn't constant anymore.
This idea that say 256 things will hash into an identical hash table entry is unlikely. Now "very, very seldom" doesn't mean "never".
Yes, and? We were talking about a worst case scenario. And a worst case scenario could be anything that doesn't never happen.

Replies are listed 'Best First'.
Re^10: elsif chain vs. dispatch
by Marshall (Canon) on Apr 28, 2009 at 04:49 UTC
    The claim was made Perl detects if too many keys hash to the same bucket, the hash is expanded in size and the keys reinserted, spreading over more buckets.

    Where did that idea come up?

    If Perl detects num_entries > num_buckets, that will trigger more buckets.