A module providing KMP-based search for strings and bytes.
Project description
kmp_util is a Python C extension module that provides efficient substring search functionality using the Knuth-Morris-Pratt (KMP) algorithm. It supports almost all Python 3 versions from 3.5 to 3.14.
Installation
pip install kmp-util
Example Usage
The kmp_util module supports searching for patterns in both byte sequences and Unicode strings.
import kmp_util
result = kmp_util.find_bytes(b'111', b'2', 1)
print(result) # Output: -1 (pattern not found)
result = kmp_util.find_str('abc中文', '文')
print(result) # Output: 4 (pattern found at index 4)
Functions
find_bytes(text: bytes, pattern: bytes, start: int = 0) -> int
Searches for the first occurrence of the byte pattern in the byte sequence.
Parameters:
text (bytes): The byte sequence to search in.
pattern (bytes): The byte pattern to search for.
start (int): The index to start the search from. Defaults to 0 if not provided.
Returns:
The starting index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.
find_str(text: str, pattern: str, start: int = 0) -> int
Searches for the first occurrence of the substring in the Unicode string.
Parameters:
text (str): The Unicode string to search in.
pattern (str): The substring to search for.
start (int): The index to start the search from. Defaults to 0 if not provided.
Returns:
The starting index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.
License
This module is open-source and available under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kmp_util-1.0.3.tar.gz.
File metadata
- Download URL: kmp_util-1.0.3.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dae6448411c0ff056dd1eee9eaadfd99e37b84e86e629d207c1594b38738531
|
|
| MD5 |
ee569d68f67509a3723ff061e55d80c6
|
|
| BLAKE2b-256 |
2a37ee96eac945574b35afeec1f41cd1c6bf65748b86aa55e7885bc90ba6afd6
|
File details
Details for the file kmp_util-1.0.3-pp311-pypy311_pp73-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-pp311-pypy311_pp73-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95fc8839d14adc5e7414e0421b1fa46b3c9dd1c19fca595e9e14788d178df8d
|
|
| MD5 |
7ecd0d4638a7408a163b52b1cc5bf41a
|
|
| BLAKE2b-256 |
f1eaa8c66dddb4570a2bc54404b2cc516cc559cc097d6c19f3b5b9e80278bffe
|
File details
Details for the file kmp_util-1.0.3-pp310-pypy310_pp73-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-pp310-pypy310_pp73-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0c05ea6093617f9002c66a8ba6e103c6fc10a5c7d78ab270090afd9387a5ae3
|
|
| MD5 |
a03c1f9f9f42a165201e6c1f6e417680
|
|
| BLAKE2b-256 |
16a85a91ec72d05e1a601e755e3dda24493b15d45fdf4c6dfa8e224e6a82764d
|
File details
Details for the file kmp_util-1.0.3-pp38-pypy38_pp73-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-pp38-pypy38_pp73-win_amd64.whl
- Upload date:
- Size: 8.5 kB
- Tags: PyPy, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b84b8195173b9a28e7b68d74b3a5103fca57bf9fc598c2f7ef33fd7480f04d39
|
|
| MD5 |
9f4c9add4ec8d4d8aab101b9d38c6225
|
|
| BLAKE2b-256 |
64df0801ee01bb0814a2eb8b290d30dd56bdeebce7d1c7f67d795f5ac67c4559
|
File details
Details for the file kmp_util-1.0.3-graalpy311-graalpy241_311_native-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-graalpy311-graalpy241_311_native-win_amd64.whl
- Upload date:
- Size: 8.5 kB
- Tags: Windows x86-64, graalpy311
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ce7b852d0e4dc420452b93587618d82e0b0db1f9c51a4bc5e876ecca975b9cc
|
|
| MD5 |
f76b2e208c2e1a2267d428527b7015c7
|
|
| BLAKE2b-256 |
27e0d86ba53bba5ba88f15b68e2d31e8200ab66091025ac235f5e9a13a293396
|
File details
Details for the file kmp_util-1.0.3-cp314-cp314t-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp314-cp314t-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.14t, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58757a1668e2691c0a5da67b198be724f3d388d2b59aa69fdf87123c0159112f
|
|
| MD5 |
56ea460835d5c8733587b6f47592398d
|
|
| BLAKE2b-256 |
1bdc88dd7abb45e398a7621ac0a4a8712c3a8c089307b3c4497a95942ea66570
|
File details
Details for the file kmp_util-1.0.3-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
294ab16c1aae8d3397d0a21c1a863f25e3905f89fbe5cfc1a4d795bd75e17b5c
|
|
| MD5 |
eaa6c36689ed80f6521ed40ac541322e
|
|
| BLAKE2b-256 |
03de39b3515478f7f30e239a5043ecb2861ba5c223807fb1caf2505be8202157
|
File details
Details for the file kmp_util-1.0.3-cp314-cp314-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp314-cp314-win32.whl
- Upload date:
- Size: 8.1 kB
- Tags: CPython 3.14, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e0c7ee41c0a837ffa1603eec60b23c4a4cd212d0a762009bc7bdd6cceea6a1f
|
|
| MD5 |
51b3e98153dd5eeeb99db2d286708b9c
|
|
| BLAKE2b-256 |
f9130c5945c2d579a540d71ffabbffca10bba7eec4468997e555937a223509fd
|
File details
Details for the file kmp_util-1.0.3-cp313-cp313t-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp313-cp313t-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.13t, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2cba102f75f5efbd1b83aea800ffe81bba52d9bc23b9bb1a6c9c14e307eaffc
|
|
| MD5 |
86b1ab2ae9a304d1d67823d338fc105b
|
|
| BLAKE2b-256 |
6a749893421f63d913bea394692a7bde004303bea6650c7bd81e09c21be84f09
|
File details
Details for the file kmp_util-1.0.3-cp313-cp313t-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp313-cp313t-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.13t, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb071c313120e16a804d1f957e84d7f912007d4acce8bb6c6969b557b5777e4d
|
|
| MD5 |
2283a902d6cb8d54db56e946c426940c
|
|
| BLAKE2b-256 |
0d4178c97bb1bff78985c4c3e6c6f2d3b77e46a8d90ccdfafc89669e70ae3a98
|
File details
Details for the file kmp_util-1.0.3-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
507d7c5da1c55ce5496275fd09dddd79e380ecc88da2ccea3265874f8898814d
|
|
| MD5 |
09a9f67902f13db12a5b185904508b37
|
|
| BLAKE2b-256 |
95fac40cb4160f25931347b9ae3c23fed433c7ff5caa1c4507234a19e390aac8
|
File details
Details for the file kmp_util-1.0.3-cp313-cp313-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp313-cp313-win32.whl
- Upload date:
- Size: 8.1 kB
- Tags: CPython 3.13, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
074eed66637724681567339a716995b8498ea9c9da9f667fa18f1fb0e704d59e
|
|
| MD5 |
94cc12ac68536fc5dfe290772e8b1b69
|
|
| BLAKE2b-256 |
0583d2f5bf975a33273ad00b5b0605b866d6f29d7e356c65dbbe695e96fe4d4d
|
File details
Details for the file kmp_util-1.0.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da03df68566ababbde2b9c407acde6cad11c30414b7a42dcbc706ed89f0bc49f
|
|
| MD5 |
2e2239020314670baf7b456c7b791933
|
|
| BLAKE2b-256 |
7d83219dae54f17225bda8f1d55c358a43471b6a85320b15fa4140d6c4adb0e7
|
File details
Details for the file kmp_util-1.0.3-cp312-cp312-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp312-cp312-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d44210de5f4c31f40e38e3785a8ae81d7f2fe994049800086d520230afbbc52
|
|
| MD5 |
a638ed68b72a25441f53791e2b8058e5
|
|
| BLAKE2b-256 |
49202be077d500e0d8cb0217a30e17efbeb735ec958ce5fe876cf4041c501113
|
File details
Details for the file kmp_util-1.0.3-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edf1cb0671674cbbd002b8c45d4a7a344e1f87f6600538a3c81de864ceab0d4e
|
|
| MD5 |
a541592b51a6874ac9e066117de13c3b
|
|
| BLAKE2b-256 |
819858234e80defa0447576a65a3dc3187b872e43c892add6b6eb85de4082633
|
File details
Details for the file kmp_util-1.0.3-cp311-cp311-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp311-cp311-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d90b5a03a9b173e99830a846071059b0d01dc5db2e8b73469c728c1c2c48e434
|
|
| MD5 |
c302549708b3c3399d351b5bfd7e66b6
|
|
| BLAKE2b-256 |
43c68c3ed81b8b889fb81a2d08a8f4c5c4a74e11d084c81b07524b46ecba69be
|
File details
Details for the file kmp_util-1.0.3-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9aa70832a0ae9adbd25ff085612b4a54366aa71d3685d5d593ef2c79228f0d5
|
|
| MD5 |
3d7a651f6056351ac025dd3b8431860f
|
|
| BLAKE2b-256 |
f027c1068e32f6c8eac532fa803f09e7b35fd49d3355d17fe747a89ce77753c6
|
File details
Details for the file kmp_util-1.0.3-cp310-cp310-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp310-cp310-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce3580c66a4c09df1ddecceef4182f4d56832072c5d69aba2b2208ed3a503f78
|
|
| MD5 |
c87e4dbbd0c632aa6583ec1eeb2dbc14
|
|
| BLAKE2b-256 |
33c132da5cddf6bb1eec52f72300a8f2f40e01ac8e9d457d964e630d14b473e0
|
File details
Details for the file kmp_util-1.0.3-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e97dad39d463c22bcee9f9976c7acdaeedb4f38b9553b22e3a64bcdf85522980
|
|
| MD5 |
2a20019527c9e71e71252bb60b3df079
|
|
| BLAKE2b-256 |
21f60c1b6b3ec48c3f3d4a87d66506ad2a2364d32c2b2813cfb6937a574f6aa1
|
File details
Details for the file kmp_util-1.0.3-cp39-cp39-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp39-cp39-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd725bc64973fe0facd3543e98916af608ec641e858f92ebdbe16e921c08758
|
|
| MD5 |
5216171fdce6a1606e47636fbe8492b3
|
|
| BLAKE2b-256 |
cb42542c397b17715b58f794a0236909d3f18c71191f44fba629734df93db9ee
|
File details
Details for the file kmp_util-1.0.3-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53870179e24efa905402a55189cb5903b8980a7f8e658389dc09fb504b7d48dc
|
|
| MD5 |
a83f31c5095b8c791a77c4187651c14d
|
|
| BLAKE2b-256 |
20ea76c72d70ee058ecb2b44deeab8eec7da5ed39484dfc65800c7f5ab8388df
|
File details
Details for the file kmp_util-1.0.3-cp38-cp38-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp38-cp38-win32.whl
- Upload date:
- Size: 8.2 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de8a530632986c1b01b38f8f9e462e87a45733a6fe1f9555a299961238c3b55
|
|
| MD5 |
9bc31947b68291b7cd9dbbb46ded1fa6
|
|
| BLAKE2b-256 |
0e0912ef880c916d75550d5435ed2cf9fd807fcfdf1c82fdc3cd0b8765b823b0
|
File details
Details for the file kmp_util-1.0.3-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5c99ed93eac31c58111ac8fca72b11728bfcc82d546b5fb42eacb16fbb5219b
|
|
| MD5 |
a96120de32610ecd8b1bd4cd09f383fa
|
|
| BLAKE2b-256 |
e797f4683a86661ea546a3befc1dc08528cef8b3f38a1c8a612d0f97e30a71f6
|
File details
Details for the file kmp_util-1.0.3-cp37-cp37m-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp37-cp37m-win32.whl
- Upload date:
- Size: 8.1 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc26b2af6713dd16d8e7304056090c28d616793b6f76a16a50b48644d9c324ea
|
|
| MD5 |
87b9da75acc5abd645c66287a96f087a
|
|
| BLAKE2b-256 |
661462521ecf4a76f83fbe643480eb02198c2c1bc8ee4a24e3e0dfa4b7b2c28a
|
File details
Details for the file kmp_util-1.0.3-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
730cc61ab3e3845048ba2d99be9c2f23ce926432e89c08e07d42095740bcff13
|
|
| MD5 |
2d8f8f5eb534796797e714a2ca8c3000
|
|
| BLAKE2b-256 |
e20268008910ec41ec84857465753fac274016cc8d68cc4911e3c8d376d88e30
|
File details
Details for the file kmp_util-1.0.3-cp36-cp36m-win32.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp36-cp36m-win32.whl
- Upload date:
- Size: 11.6 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f541f5f25d5ab7dd0695e5d4e389e7d01c6e323134543770df6a5b951cdf45
|
|
| MD5 |
f9d984f224c76e4cc30223665667d0f0
|
|
| BLAKE2b-256 |
ae38d55c512d7779d3c9febca4f6e8380c6ec5a650fe50605d9247ccd610c3aa
|
File details
Details for the file kmp_util-1.0.3-cp35-cp35m-win_amd64.whl.
File metadata
- Download URL: kmp_util-1.0.3-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 8.4 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7991620c9d29c14532661853feefc56634562ba0ce54bc8d458c225b2683a0
|
|
| MD5 |
7e4fb073d6c90aada898275e9a228017
|
|
| BLAKE2b-256 |
d35d9ceeefcd73fb637d2d5c06c53a884b1d29f0653098c22904bd0aa7e72634
|