Perl's hashing algorithm may be coming up with the same hash for each key. After the hash is constructed, try print scalar %arrangements; to see how many buckets are used/allocated for the hash.
Update: Take a look at this:
#!/usr/bin/perl use strict; use warnings; use Algorithm::FastPermute; #uncomment the following line and comment out the next to see the diff #my @array = (0 .. 7); my @array = (100_000 .. 100_007); my ($key, %perm); permute {$key = join '',@array;$perm{$key} = 1} @array; print scalar %perm;
Using 0..7, the code runs very quickly and uses 3704 out of 8192 buckets for 40_320 values. However, using 100_000..100_007 it uses 4 out of 8 buckets (for the same number of values) and runs very slowly - effectively turning perl's fast hashing algorithm into an expensive linear search.
In reply to Re: constructing large hashes
by jsprat
in thread constructing large hashes
by duelafn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |