lemire / fastconstmap
PublicFast, immutable, compact map from strings to 64-bit integers β for Python.
FastConstMap is a Python library that creates super-fast, memory-efficient lookup tables mapping text strings to numbers. Built in the C programming language for speed, it can find values in a fraction of the time and uses about 13 times less memory than regular Python dictionaries. It offers two modes: a minimal version for maximum speed, and a verified version that safely detects when someone asks for a key that doesn't exist. The lookup tables can be saved to files or shared across multiple programs running at the same time without copying the data. This is useful for applications that need to look up millions of items quickly, like matching product codes, checking identifiers, or finding records by name.
How It Works
Your application needs to look up millions of text labels and get back numbers, and regular dictionaries are too slow or use too much memory.
With one simple command, the library installs on your computer and is ready to use in your Python projects.
You give the library a list of text-to-number pairs, and it builds a lightning-fast lookup structure behind the scenes.
Finding a value takes only a tiny fraction of a second, even with millions of entries, and your computer uses far less memory than before.
Ultra-fast and tiny, perfect when you know all your lookups will be valid.
Slightly larger but catches mistakes, behaving like a normal dictionary with error checking.
Your lookup table can be saved to a file or shared across multiple running programs without copying, so everyone sees the same data instantly.
Your application runs faster, uses less memory, and your lookups happen so quickly your users barely notice the wait.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.