MCPcopy Index your code
hub / github.com/ashvardanian/StringZilla

github.com/ashvardanian/StringZilla @v4.6.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.6.2 ↗ · + Follow
2,477 symbols 5,905 edges 62 files 700 documented · 28% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

StringZilla 🦖

StringZilla banner

Strings are the first fundamental data type every programming language implements in software rather than hardware, so dedicated CPU instructions are rare - and the few that exist are hardly ideal. That's why most languages lean on the C standard library (libc) for their string operations, which, despite its name, ships its hottest code in hand-tuned assembly. It does exploit SIMD, but it isn't perfect. 1️⃣ Even on ubiquitous hardware - over a billion 64-bit ARM CPUs - routines such as strstr and memmem top out at roughly one-third of available throughput. 2️⃣ SIMD coverage is uneven: fast forward scans don't guarantee speedy reverse searches, hashing and case-mapping is not even part of the standard. 3️⃣ Many higher-level languages can't rely on libc at all because their strings aren't NUL-terminated - or may even contain embedded zeroes. That's why StringZilla exists: predictable, high performance on every modern platform, OS, and programming language.

StringZilla Python installs StringZilla Rust installs StringZilla code size

StringZilla is the GodZilla of string libraries, using SIMD and SWAR to accelerate binary and UTF-8 string operations on modern CPUs and GPUs. It delivers up to 10x higher CPU throughput in C, C++, Rust, Python, and other languages, and can be 100x faster than existing GPU kernels, covering a broad range of functionality. It accelerates exact and fuzzy string matching, hashing, edit distance computations, sorting, provides allocation-free lazily-evaluated smart-iterators, and even random-string generators.

  • 🐂 C: Upgrade LibC's <string.h> to <stringzilla/stringzilla.h> in C 99
  • 🐉 C++: Upgrade STL's <string> to <stringzilla/stringzilla.hpp> in C++ 11
  • 🧮 CUDA: Process in-bulk with <stringzillas/stringzillas.cuh> in CUDA C++ 17
  • 🐍 Python: Upgrade your str to faster Str
  • 🦀 Rust: Use the StringZilla traits crate
  • 🦫 Go: Use the StringZilla cGo module
  • 🍎 Swift: Use the String+StringZilla extension
  • 🟨 JavaScript: Use the StringZilla library
  • 🐚 Shell: Accelerate common CLI tools with sz- prefix
  • 📚 Researcher? Jump to Algorithms & Design Decisions
  • 💡 Thinking to contribute? Look for "good first issues"
  • 🤝 And check the guide to set up the environment
  • Want more bindings or features? Let me know!

Who is this for?

  • For data-engineers parsing large datasets, like the CommonCrawl, RedPajama, or LAION.
  • For software engineers optimizing strings in their apps and services.
  • For bioinformaticians and search engineers looking for edit-distances for USearch.
  • For DBMS devs, optimizing LIKE, ORDER BY, and GROUP BY operations.
  • For hardware designers, needing a SWAR baseline for string-processing functionality.
  • For students studying SIMD/SWAR applications to non-data-parallel operations.

Performance

C C++ Python StringZilla
Unicode case-folding, expanding characters like ßss
.casefold x86: 0.4 GB/s sz.utf8_case_fold x86: 1.3 GB/s
Unicode case-insensitive substring search
icu.StringSearch x86: 0.02 GB/s utf8_case_insensitive_find x86: 3.0 GB/s
find the first occurrence of a random word from text, ≅ 5 bytes long
strstr 1 x86: 7.4 · arm: 2.0 GB/s .find x86: 2.9 · arm: 1.6 GB/s .find x86: 1.1 · arm: 0.6 GB/s sz_find x86: 10.6 · arm: 7.1 GB/s
find the last occurrence of a random word from text, ≅ 5 bytes long
.rfind x86: 0.5 · arm: 0.4 GB/s .rfind x86: 0.9 · arm: 0.5 GB/s sz_rfind x86: 10.8 · arm: 6.7 GB/s
split lines separated by \n or \r 2
strcspn 1 x86: 5.42 · arm: 2.19 GB/s .find_first_of x86: 0.59 · arm: 0.46 GB/s re.finditer x86: 0.06 · arm: 0.02 GB/s sz_find_byteset x86: 4.08 · arm: 3.22 GB/s
find the last occurrence of any of 6 whitespaces 2
.find_last_of x86: 0.25 · arm: 0.25 GB/s sz_rfind_byteset x86: 0.43 · arm: 0.23 GB/s
Random string from a given alphabet, 20 bytes long 3
rand() % n x86: 18.0 · arm: 9.4 MB/s uniform_int_distribution x86: 47.2 · arm: 20.4 MB/s join(random.choices(x)) x86: 13.3 · arm: 5.9 MB/s sz_fill_random x86: 56.2 · arm: 25.8 MB/s
Mapping characters with lookup table transforms
std::transform x86: 3.81 · arm: 2.65 GB/s str.translate x86: 260.0 · arm: 140.0 MB/s sz_lookup x86: 21.2 · arm: 8.5 GB/s
Get sorted order, ≅ 8 million English words 4
qsort_r x86: 3.55 · arm: 5.77 s std::sort x86: 2.79 · arm: 4.02 s numpy.argsort x86: 7.58 · arm: 13.00 s sz_sequence_argsort x86: 1.91 · arm: 2.37 s
Levenshtein edit distance, text lines ≅ 100 bytes long
via NLTK 5 and CuDF x86: 1,615,306 · arm: 1,349,980 · cuda: 6,532,411,354 CUPS szs_levenshtein_distances_t x86: 3,434,427,548 · arm: 1,605,340,403 · cuda: 93,662,026,653 CUPS
Needleman-Wunsch alignment scores, proteins ≅ 1 K amino acids long
via biopython 6 x86: 575,981,513 · arm: 436,350,732 CUPS szs_needleman_wunsch_scores_t x86: 452,629,942 · arm: 520,170,239 ·

Extension points exported contracts — how you extend this code

Utf8CaseInsensitiveNeedleArg (Interface)
Trait for types that can be used as a case-insensitive search needle. This trait is implemented for: - Any type impleme [2 …
rust/stringzilla.rs
SzSequenceFromBytes (Interface)
Trait for types that can be converted to SzSequence for byte sequences [1 implementers]
rust/stringzillas.rs
SequenceData (Interface)
A trait for types that support indexed lookup. [1 implementers]
rust/stringzilla.rs
SzSequenceFromChars (Interface)
Trait for types that can be converted to SzSequence for string sequences [1 implementers]
rust/stringzillas.rs
StringZillableUnary (Interface)
Trait for unary string operations that only operate on `self` without needle parameters. These operations include hash c [1 …
rust/stringzilla.rs
StringZillableBinary (Interface)
Trait for binary string operations that take a needle parameter. These operations include searching, splitting, and patt [1 …
rust/stringzilla.rs
Matcher (Interface)
(no doc) [1 implementers]
rust/stringzilla.rs

Core symbols most depended-on inside this repo

size
called by 471
include/stringzilla/types.hpp
utf8_case_insensitive_find
called by 263
include/stringzilla/stringzilla.hpp
data
called by 214
include/stringzilla/types.hpp
bench_unary
called by 158
scripts/bench.hpp
len
called by 123
rust/stringzilla.rs
size
called by 119
include/stringzillas/types.hpp
sz_u64_mask_until_
called by 115
include/stringzilla/types.h
size
called by 102
include/stringzilla/stringzilla.hpp

Shape

Function 1,286
Method 890
Class 274
Enum 15
Interface 7
Struct 3
Route 2

Languages

C++67%
Rust12%
C12%
Python7%
Go2%

Modules by API surface

include/stringzilla/stringzilla.hpp419 symbols
rust/stringzilla.rs227 symbols
python/stringzilla.c169 symbols
include/stringzillas/similarities.hpp139 symbols
include/stringzilla/types.hpp117 symbols
include/stringzilla/hash.h103 symbols
scripts/test_stringzilla.py96 symbols
include/stringzillas/fingerprints.hpp96 symbols
scripts/bench_find.cpp79 symbols
include/stringzilla/utf8_case.h75 symbols
rust/stringzillas.rs72 symbols
include/stringzilla/types.h67 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add StringZilla \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact