On Thu, Sep 06, 2001 at 06:29:15AM -0500, David L. Nicol wrote:
> Hashes also waste a lot of space.
<record type=broken>
Perl hashes are only 15% larger/slower than Perl arrays.
</record>
Having implemented a number of pure Perl tree structures (although
pretty badly...) I can tell you it's definitely a losing game.
In Big O terms, the C swamps the benefits of the O.
my @sorted_keys = sort keys %hash;
will remain much faster than
my @sorted_keys = $tree->keys;
even for extremely large numbers of keys, because your $tree is
written in Perl and the %hash is written in highly optimized C.
Perl don't do this sort of thing very well. Or to look at it another
way, Perl does this sort of thing so well, you don't have to bother.
Implement a tree because you need that particular structure, not
because it's a faster/smaller hash.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
My breasts are arousing weapons.