
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Low memory overhead alternative to Python's dict
, with string keys and values.
Uses half of the memory of dict
for strings of length 40, at the cost of being
half as fast. More improvement at shorter strings, less at longer ones. See more
at benchmarks.
Drop-in replacement for dict
with the following limitations:
>>> from strstrdict import StrStrDict
>>> d = StrStrDict()
>>> d['foo'] = 'bar'
>>> d['foo']
'bar'
To KISS, this project only supports a string to string dictionary.
More:
pip install strstrdict
Filling a dictionary with 1m items, key and value strings 5-10 chars long, from a pool of 2m random strings. Then reading values 1m times, with a 50% hit rate.
Fill time (s) | Read time (s) | Memory (MB) | |
---|---|---|---|
dict | 0.19s | 0.17s | 159.60 |
sqlitedict1 | 10.31s | 51.79s | 69.41 |
strstrdict | 0.41s | 0.44s | 64.44 |
Filling a dictionary with 1m items, key and value strings 20-30 chars long, from a pool of 2m random strings. Then reading values 1m times, with a 50% hit rate.
Fill time (s) | Read time (s) | Memory (MB) | |
---|---|---|---|
dict | 0.26s | 0.21s | 193.23 |
sqlitedict1 | 9.17s | 41.09s | 139.40 |
strstrdict | 0.41s | 0.42s | 95.38 |
Filling a dictionary with 1m items, key and value strings 100-200 chars long, from a pool of 2m random strings. Then reading values 1m times, with a 50% hit rate.
Fill time (s) | Read time (s) | Memory (MB) | |
---|---|---|---|
dict | 0.38s | 0.24s | 447.02 |
sqlitedict1 | 11.31s | 42.62s | 572.88 |
strstrdict | 0.76s | 0.56s | 344.73 |
parallel-hashmap for their amazing header-only library!
pysimdjson for a reference how to write a cython lib!
FAQs
lower memory alternative to string-to-string dict
We found that strstrdict demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.