Pseudo-hashes: Threat or Menace?

KM on 2001-07-16T12:06:46

Schwern writes "Whichever they are, they're gone. As of 5.7.2, the current pseudo-hash implementation has been deprecated. The experiment will finally be expunged in 5.10.0 to be replaced with something better.

If you don't know what a pseudo-hash is, you're not alone. This little bastard of a data type was an attempt to merge the speed and compactness of arrays with the convenience of hashes and the fixed keysets of C-style structs. This was in May, 1997. Four years later and the bugs haven't been ironed out. The fundemental problems were presented in thePerl 6 RFC #241 "Pseudo-hashes must die!" advocating the elimination of this type from Perl 6 in favor of any number of better proposals for fixed-key hashes."

But this wasn't soon enough to get rid of the buggers. The question was asked of perl5-porters, "Must pseudo-hashes die?" proposing that the experiment be terminated in Perl 5 as well. The final nail in the coffin was the discovery that Pseudo-hashes drag on performance. The extra code to support pseudo-hashes slowed down all arrays and hashes by 10 to 15%. Much more important features have been killed for much less (safe signals were shelved for as little as 5% reduction in speed).

So pseudo-hashes are officially deprecated in 5.7.2 (and thus 5.8.0) and the current implementation will be purged completely from 5.10.0. Somethings will not be changing. The fields.pm module interface will remain, so if you have code which creates pseudo-hashes, switch over to fields.pm. Its not known yet what will replace pseudo-hashes, possibly something involving the new variable attributes, but there will be some way to have high-performance, fixed key hashes in 5.10.0. In the meantime, Tie::SecureHash is probably your best bet.


Build option?

pudge on 2001-07-16T12:31:02

Maybe there could be a way to disable pseudohashes in perl right now, and check $Config{has_pseudohashes} to see if they are available? :)

Can they be disabled now?

clintp on 2001-07-17T12:23:13

Can we get that performance increase right now, instead of having to wait for 5.8.x to peter itself out? Is there a configure option to get rid of it now?

I don't really care (for myself) about the backward compatability problems that might arise from doing this!

Re:Can they be disabled now?

schwern on 2001-07-17T18:43:42

That's my plan (I have no idea if Jarko would go for it) but it can't be done in time for 5.8.0.



Meantime, you can play around with the patch I did to tear pseudo-hashes out and benchmark. WARNING! I used a heavy, rusty, dull hacksaw to rip them out, this is not a pleasant patch.