Skip to main content

Python/Cython implementation of Boyer-Moore string-search algorithm

Project description

Build Status codecov PyPI version PyPI - Python Version Code style: black

pybmoore

Python/Cython implementation of Boyer-Moore string-search algorithm.

Installing

Install and update using uv:

uv pip install pybmoore

notice: gcc must be available on the system.

Usage

Single term

The search method in the pybmoore module will return a list of tuples with all occurrences, where the tuple have the initial and final position. For example:

import pybmoore


TEXT = """The Boyer–Moore string-search algorithm is 
an efficient string-searching algorithm that is the 
standard benchmark for practical string-search literature.
"""

matches = pybmoore.search('string', TEXT)
print(f"Occurrences: {len(matches)}")
# output: Occurrences: 3

print(matches)
# output: [(16, 22), (57, 63), (130, 136)]

for x, y in matches:
    print(f"({x},{y}) - {TEXT[x:y]}")

notice: search method it's case sensitive.

import pybmoore


TEXT = """The algorithm preprocesses the string being searched for (the pattern), 
but not the string being searched in (the text). It is thus well-suited for 
applications in which the pattern is much shorter than the text or where it 
persists across multiple searches.
"""

pybmoore.search('algorithm', TEXT)
# output: [(4, 13)]

pybmoore.search('Algorithm', TEXT)
# output: []

Multiple terms

from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor

import pybmoore


TEXT = """The Boyer-Moore algorithm searches for occurrences of P in T by 
performing explicit character comparisons at different alignments. Instead of a 
brute-force search of all alignments (of which there are m − n + 1, Boyer-Moore 
uses information gained by preprocessing P to skip as many alignments as possible.
"""

# Using a list of patterns
pybmoore.search_m(['brute-force', 'Boyer-Moore'], TEXT, ProcessPoolExecutor)
# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}

# Using a set of patterns
pybmoore.search_m({'brute-force', 'Boyer-Moore'}, TEXT, ThreadPoolExecutor)
# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}

# Using a tuple of patterns
pybmoore.search_m(('brute-force', 'Boyer-Moore'), TEXT, ThreadPoolExecutor, max_workers=4)
# output: {'brute-force': [(146, 157)], 'Boyer-Moore': [(4, 15), (214, 225)]}

Details

For granular control of the pool, use the parameters listed in the module documentation. For example:

Development

To build pybmoore locally first install requirements-dev.txt dependencies and run:

make build # without Cython

make build USE_CYTHON=1 # with Cython

in some cases it's necesary run make clean before make build.

Type make in the command line to see all available targets.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pybmoore-2.2.0-cp314-cp314-musllinux_1_2_x86_64.whl (184.9 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pybmoore-2.2.0-cp314-cp314-musllinux_1_2_aarch64.whl (181.9 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ ARM64

pybmoore-2.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (183.2 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pybmoore-2.2.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (184.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pybmoore-2.2.0-cp313-cp313-musllinux_1_2_x86_64.whl (186.3 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pybmoore-2.2.0-cp313-cp313-musllinux_1_2_aarch64.whl (181.9 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pybmoore-2.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (182.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pybmoore-2.2.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (185.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pybmoore-2.2.0-cp312-cp312-musllinux_1_2_x86_64.whl (189.2 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pybmoore-2.2.0-cp312-cp312-musllinux_1_2_aarch64.whl (184.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pybmoore-2.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (186.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pybmoore-2.2.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (188.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pybmoore-2.2.0-cp311-cp311-musllinux_1_2_x86_64.whl (184.8 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pybmoore-2.2.0-cp311-cp311-musllinux_1_2_aarch64.whl (179.0 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pybmoore-2.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (180.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pybmoore-2.2.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (183.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pybmoore-2.2.0-cp310-cp310-musllinux_1_2_x86_64.whl (170.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pybmoore-2.2.0-cp310-cp310-musllinux_1_2_aarch64.whl (167.6 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ ARM64

pybmoore-2.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (168.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pybmoore-2.2.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (171.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

File details

Details for the file pybmoore-2.2.0-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f5a890bd5a2a147e973b8eaaffa68269994ea918bb6c814abbf98d6363788f2c
MD5 53f4189806af2d9d6a8aec81d16f7e75
BLAKE2b-256 87ba7468d5220127c10a8a5cbaebefcc879a1261aafef90f76841e379309d6f6

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp314-cp314-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp314-cp314-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 db2e95cfae58375da64cac5a32107c14f2895d55c327ca9ae7a3f7ce701052a0
MD5 342acc012d752a62b5ce8aed6ecbf260
BLAKE2b-256 34179b8309de1e8bc043870bef507daeb4676a1e4c371ee2886356598d060c89

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 56a8b43d8cb4ad9c8a29c500add6c9d7cb0067d10fcfed389547e545c83d4966
MD5 05b0c7c2a935afbe90ccadb667fd67bc
BLAKE2b-256 7f5cb97d06d8f876193c90be241be6748dd9dfab4faa3c0a773e6668d6fff596

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 aa7b109c67fe23bd2625af5e828070fb1a750390f1873c6ada1d9b58bb55ffd5
MD5 de5adac83a1c20d74bf6bf367406227f
BLAKE2b-256 9ef8d35400ca19d1fe55c1032d02ba972bd469e28ae47bd49065f51e1d5e89ac

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8a7cdec6548845c767ed2df2d3cc14156a5ac8461220a9a730ec1239ee7c9901
MD5 e959cba6a620f9f9f45eebbe5a849627
BLAKE2b-256 f1dffa9482e86e6b78b613687db7722d28f1879c7418e7a6a1d8eda8401e973b

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 55ecaa9ea47cbcb11bf83c1b7491e5363c32e1d79360cc3b15e2fe2d94d8df66
MD5 468bb217dbfb38262f70285fcc094fdd
BLAKE2b-256 f65b003216f105300117c2185333f07adecad0947173b76af23c184b47b75c14

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f8ec43fe16104cdd767ceda02e4baf71b3bd62a89d52b7d316446362718a0a14
MD5 a0d689fca89a935ea2c0398c2cc626f7
BLAKE2b-256 06ee2c0722bf917125d668e8133134a9f610b22fdf5c69d91644a6b41f5ba5e3

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 97ca98ff407d8052835e54a1ea2fd86e80a8b540cf7895d8862fe1bb2e5d3088
MD5 add46d1bafa23c92750f70c59e268ac6
BLAKE2b-256 ea4d6ceff7396eb2bbd368ab63f1a2d0cbb12288658743aec5f4e83c8e86eb62

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d3c3c061e6640a85f06bb3dcc683e10e65ca69f75029f13ab6abf91593b7ad3f
MD5 6e00e4a240ff5316f035ee46ffcc75e7
BLAKE2b-256 a415b02f3c1110c62e9435821ca736fae55cef14cdba0451cfe83f5670379f79

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b31f64fff57c0d414d09655eb2f52fdccf8cce9a5105159c634d842fac6bf22d
MD5 76db9141c91acb6a9bf2bec55b2c797f
BLAKE2b-256 a9e32bb90a205ed1da60359229ee79b86895080c2212adacf0000d735e4fee62

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 266a90509d4fda23dd395bbb4bd46b60ee1e3513aafbf18752a72d40cc9a7f84
MD5 f3bcc50a06bccf38c1707bba92e22c15
BLAKE2b-256 d4c18dfe34ef20f65c516904fa300c66fba1ef33ead7bd374ff3099b66cc7d83

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e8f1b0a0ed605c144e7e6388a54d785c68bd6856a44da93f52ab707a7afae7bb
MD5 935dc5f4a1143c12267deaf33c989b5c
BLAKE2b-256 cc7da5e9d4765e92d3fbc5a07464aa762a48d9ad319ee59a178d0782c90b2bed

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d0fe5074c35979fb5b850dee27a07a9031d5794ff60aac8f94cec973c43022ef
MD5 7f4d0a848e6119b77357f11c76d945a7
BLAKE2b-256 58b38912fbc9e5856f2ef8e29464b8aa54076abec46686627e9194fdf3927e30

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e2ca738ac35b09f1febb03c7e8074f11fa75d279e054830c5ff18b7ac0f37eaa
MD5 1b803f30464c242ac0f9e2583a5a0afb
BLAKE2b-256 f3a155ccec05ca767ef6fac14fa90b0998eae257c21a63453ae5a774e798b371

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1fbcdd6763bad718925f153e6008656a11f35dd3ce6feced498eca0586c56257
MD5 73d4976f7332d28b5a814d18312cfe14
BLAKE2b-256 b742eaad102b9703a0cb1d913cfd6fd8ab66ed6c0d7498f8f89032a087035607

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4c42132ca3b448c6a3db9102bc8069f19b30fb0e20aae42d97dc439c9bf89eea
MD5 83308d7114d7afcef9d0a885aca0f2a9
BLAKE2b-256 f13592030e866850ffbe3ebcf451ed0870dff3bfd5d0c9c8693f5f76811d49a9

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 853d87c51b3b175c09d3f9a4d6e8629ac7de161330fd79125337cc5f1ecb8f5d
MD5 cdb4f15911abd89c1ae3f94675909c9d
BLAKE2b-256 81840f097da0bce286f5fab525b260de142f434d487b2c780854d411be81ade3

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp310-cp310-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f893ae6c59c43da0154d2c89ca090dbac86abee821dae79f09b5b77ca3224fb1
MD5 7b1bbe564faa22e94420902f2e584611
BLAKE2b-256 9e9f20ee1a568e7aa8e6f867b7f6ed55bd3629c65910f1f9b04905f91dd8cee5

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 75bc409a978ab38547b7a4c572cf1a835a8502f2e2b795361da7b2dcff027a54
MD5 632ae16449e15885f72242858190831e
BLAKE2b-256 294e9478c32bba7c08f30dd55e0719bc529be719b6a0e659ae05f8b559523c2b

See more details on using hashes here.

File details

Details for the file pybmoore-2.2.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pybmoore-2.2.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 54b94fede963dbd424455a02a018687952e60ccbf47a5e6ea5035f6122507998
MD5 efddc99210c463757ae360862322878d
BLAKE2b-256 ab44b543eb4692d7593040262edf751b417df72ff2d2f4446c8ff1733d43786b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page