in reply to constructing large hashes
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: constructing large hashes
by LEFant (Scribe) on Oct 01, 2002 at 01:36 UTC | |
by jsprat (Curate) on Oct 01, 2002 at 01:50 UTC | |
Re: Re: constructing large hashes
by blssu (Pilgrim) on Sep 30, 2002 at 21:55 UTC | |
by BazB (Priest) on Sep 30, 2002 at 22:03 UTC | |
Re: Re: constructing large hashes
by duelafn (Parson) on Oct 01, 2002 at 00:20 UTC | |
by jsprat (Curate) on Oct 01, 2002 at 01:08 UTC | |
by thor (Priest) on Oct 02, 2002 at 11:23 UTC |