phash2 isn't very resistant to collisions?

Roger Lipscombe <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAJgnQd-4PuOFt783by==JKBN4tZYuDmkGv0rK=T0Zm40_R9WiA@mail.gmail.com>
I'm sure this has come up previously, but all I could find talked about atoms.

I know it's not intended to be cryptographically strong, but
erlang:phash2 is woefully collidey with 2-tuples:

Test = fun(N) ->
    L = [{X, Y} || X <- lists:seq(0, N - 1), Y <- lists:seq(0, N - 1)],
    Expected = N * N,
    Expected = length(L),
    Expected = length(lists:usort([erlang:phash2(Term) || Term <- L]))
end.

1> Test(10).
100

2> Test(100).
** exception error: no match of right hand side value 9999

3> Test(99).
** exception error: no match of right hand side value 9800

4> Test(500).
** exception error: no match of right hand side value 249763

What alternatives are there to phash2, if I still care about performance?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.