in reply to Re^4: Generating Unique numbers from Unique strings
in thread Generating Unique numbers from Unique strings

An array access by index will be faster than a hash table lookup, but not by all that much unless you do this a bazillion times.

Accessing an array is measurably, and for some things substantially, faster than accessing a hash; but the big problems with using an array for the OPs usage are:

  1. Creating an array that has 4 billion slots;
  2. Or truncating the 32-bit value to some more reasonable size and then dealing with collisions.

Perl's hashes take care of this; and do so very efficiently.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: Generating Unique numbers from Unique strings
by Marshall (Canon) on Apr 03, 2016 at 19:56 UTC
    I agree completely.