perfecthash

A perfect hashing library for mapping bytestrings to values.

Latest on Hackage:0.2.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed and maintained by Mark Wotton
This is an immutable hashtable built on cmph.

The motivation is mostly speed, and wren thornton's bytestring-trie seems to be the main competition:

% ./dist/build/benchmark_trie/benchmark_trie
* trie lookup: 1.136ns per iteration / 880403.98 per second.

% ./dist/build/benchmark/benchmark
* perfect lookup: 0.687ns per iteration / 1456455.69 per second.

it also uses less space in the haskell heap, building once and doing the same number of lookups:

PerfectHash:
total alloc = 2,525,223,964 bytes (excludes profiling overheads)

Trie:
total alloc = 9,806,202,096 bytes (excludes profiling overheads)

although this is not an entirely fair comparison given how much PerfectHash stores on the C side.
comments powered byDisqus