|P is for Practical|
> But your simple elegant code is relying on implicit stringification, and repeated stringification of the same values. This is inefficient if it's a complex data structure, and needs an explicit call in the general code to handle ad-hoc data structures that are not blessed into a class with a stringify operator that's suitable for this purpose.
In Perl stringification of references has no performance penalty. It's just a string with the reference addressą and the type (this includes package name if blessed).
(I think you are confusing with other language like JS˛, where the whole data is dumped)
OTOH, there is a doubled memory consumption when using primitive scalars like long strings.
>As for getting a fake "" key you need to toss out, I don't think that's a problem if you make sure that the stringification never returns "" for a valid item in the set.
well I think a special case handling "" wouldn't cost too much performance...it's just not elegant anymore.
> Ultimately, I think the answer to "how do I find an intersection" isn't to repeat some incantation invented by someone else, but to simply call intersection. The algorithm should be canned in a CPAN module.
There is already Set::Object which seems to follow the same ideas, but it looks heavy and uses inline C...
Anyway my point was first to improve the FAQ and then thinking about a module.
1) Of course one should be careful when mixing strings and references in one set... :)