@hackage symbolize1.0.0.0
Efficient global Symbol table, with Garbage Collection.
Categories
License
BSD-3-Clause
Maintainer
qqwy@gmx.com
Links
Versions
Installation
Dependencies (8)
- base >=4.7 && <5
- bytestring >=0.11.0 && <0.13
- containers >=0.6.0 && <0.7
- deepseq >=1.4.0 && <1.6
- random >=1.2 && <2
- text >=2.0 && <2.2 Show all…
Dependents (0)
Symbols, also known as Atoms or Interned Strings, are a common technique to reduce memory usage and improve performance when using many small strings.
By storing a single copy of each encountered string in a global table and giving out pointers to the stored keys,
it is possible to compare strings for equality in constant time, instead of linear (in string size) time.
Furthermore, by using StableName
, hashing of Symbols also takes constant-time, so Symbol
s make great hashmap keys!.
The main advantages of Symbolize over other symbol table implementations are:
Garbage collection: Symbols which are no longer used are automatically cleaned up.
Support for any
Textual
type, includingString
, (strict and lazy)Data.Text
, (strict and lazy)Data.ByteString
,ShortText
,ShortByteString
, etc.Great memory usage:
Symbol
s are simply a (lifted) wrapper around aByteArray#
, which is nicely unpacked by GHC.The symbol table is an
IntMap
that contains weak pointers to these sameByteArray#
s and their associatedStableName#
sGreat performance:
unintern
is a simple pointer-dereferencecalls to
lookup
are free of atomic memory barriers (and never have to wait on a concurrent thread runningintern
)Thread-safe
Please see the full README below or on GitHub at https://github.com/Qqwy/haskell-symbolize#readme