bmb-text — Fast String Processing
KMP search, substring operations, case conversion, and text analysis compiled from BMB.
Installation
pip install bmb-text
Quick Start
import bmb_text
bmb_text.kmp_search("hello world", "world") # 6
bmb_text.str_replace_all("abcabc", "abc", "X") # "XX"
bmb_text.to_upper("hello") # "HELLO"
bmb_text.trim(" hello ") # "hello"
bmb_text.is_palindrome("racecar") # True
bmb_text.word_count("hello world") # 2
bmb_text.repeat("ab", 3) # "ababab"
bmb_text.hamming_distance("karolin", "kathrin") # 3
Full API (23 functions)
Search
| Function | Description |
|---|---|
kmp_search(text, pattern) |
KMP substring search O(n+m), returns index or -1 |
str_find(haystack, needle) |
Find first occurrence |
str_rfind(haystack, needle) |
Find last occurrence |
str_count(haystack, needle) |
Count non-overlapping occurrences |
str_contains(haystack, needle) |
Contains check |
str_starts_with(s, prefix) |
Prefix check |
str_ends_with(s, suffix) |
Suffix check |
find_byte(s, byte) |
Find byte value in string |
count_byte(s, byte) |
Count byte occurrences |
Transform
| Function | Description |
|---|---|
str_reverse(s) |
Reverse string |
str_replace(s, old, new) |
Replace first occurrence |
str_replace_all(s, old, new) |
Replace all occurrences |
to_upper(s) |
Convert to UPPERCASE |
to_lower(s) |
Convert to lowercase |
trim(s) |
Trim leading/trailing whitespace |
repeat(s, n) |
Repeat string n times |
Analysis
| Function | Description |
|---|---|
is_palindrome(s) |
Palindrome check |
hamming_distance(a, b) |
Hamming distance between equal-length strings |
word_count(s) |
Count whitespace-separated words |
token_count(s, delimiter) |
Count delimiter-separated tokens |
str_len(s) |
String length in bytes |
str_char_at(s, idx) |
Byte value at index (-1 if OOB) |
str_compare(a, b) |
Lexicographic comparison |
How?
Written in BMB — compile-time contracts prove correctness, then generate code faster than hand-tuned C.
License
MIT
Metadata
Release files for bmb-text 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bmb_text-0.2.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| bmb_text-0.2.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| bmb_text-0.2.0-py3-none-macosx_15_0_universal2.whl | Python 3 | none | macOS 15.0+ universal2 (ARM64, x86-64) | Details |
Total release size: 208.0 kB
Release files / bmb_text-0.2.0-py3-none-win_amd64.whl
| Download URL | bmb_text-0.2.0-py3-none-win_amd64.whl |
|---|---|
| Size | 87.9 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
dd3abab5ce6c7e8c5df2ab79e04fc957032f4755b30199fd96947ec7154ee3ba
|
|
BLAKE2b-256 checksum How to use checksums |
4571dfaadb89976563804d06a42637cac331cb99c5aa9f5c0e71e452b91f6884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / bmb_text-0.2.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | bmb_text-0.2.0-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 69.3 kB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
d06aa52e3732c75505e2367cdf0e935db80303b83d6e09de5fe52fabbb1ce080
|
|
BLAKE2b-256 checksum How to use checksums |
b72ed22df78cacb8842832f0d58cc4a02c64492e746ae2d0d39fd7b79393e4af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / bmb_text-0.2.0-py3-none-macosx_15_0_universal2.whl
| Download URL | bmb_text-0.2.0-py3-none-macosx_15_0_universal2.whl |
|---|---|
| Size | 50.9 kB |
| Tags | Python 3 macOS 15.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
c0dd6d05c0b2f669d6abfd14ce42a46bf21186852885a58826ca1ea944d95b5f
|
|
BLAKE2b-256 checksum How to use checksums |
ce08a8d22b4c904670704ee3dfefa7f3ccd236fadf4fddf37c9e4c9db3017226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|