Skip to main content

Logo

A Python library written in Rust that searches for substrings quickly using a Suffix Array

license Python Build PyPi

Table of Contents

About The Project

PySubstringSearch is a library designed to search over an index file for substring patterns. In order to achieve speed and efficiency, the library is written in Rust. For string indexing, the library uses libsais suffix array construction library. The index created consists of the original text and a 32bit suffix array struct. To get around the limitations of the Suffix Array Construction implementation, the library uses a proprietary container protocol to hold the original text and index in chunks of 512MB.

The module implements a method for searching.

  • search - Find different entries with the same substring concurrently. Concurrency increases as the index file grows in size with multiple inner chunks.
  • search_multiple - same as search but accepts multiple substrings in a single call

Built With

Performance

500MB File

Library Function Time #Results Improvement Factor
ripgrepy Ripgrepy('google', '500mb').run().as_string.split('\n') 47.2ms 5943 1.0x
PySubstringSearch reader.search('google') 497µs 5943 95x
ripgrepy Ripgrepy('text_two', '500mb').run().as_string.split('\n') 44.7ms 159 1.0x
PySubstringSearch reader.search('text_two') 14.9µs 159 3000x

7500MB File

Library Function Time #Results Improvement Factor
ripgrepy Ripgrepy('google', '6000mb').run().as_string.split('\n') 900ms 62834 1.0x
PySubstringSearch reader.search('google') 10.1ms 62834 89.1x
ripgrepy Ripgrepy('text_two', '6000mb').run().as_string.split('\n') 820ms 0 1.0x
PySubstringSearch reader.search('text_two') 200µs 0 4100x

Installation

pip3 install PySubstringSearch

Usage

Create an index

import pysubstringsearch

# creating a new index file
# if a file with this name is already exists, it will be overwritten
writer = pysubstringsearch.Writer(
    index_file_path='output.idx',
)

# adding entries to the new index
writer.add_entry('some short string')
writer.add_entry('another but now a longer string')
writer.add_entry('more text to add')

# adding entries from file lines
writer.add_entries_from_file_lines('input_file.txt')

# making sure the data is dumped to the file
writer.finalize()

Search a substring within an index

import pysubstringsearch

# opening an index file for searching
reader = pysubstringsearch.Reader(
    index_file_path='output.idx',
)

# lookup for a substring
reader.search('short')
>>> ['some short string']

# lookup for a substring
reader.search('string')
>>> ['some short string', 'another but now a longer string']

# lookup for multiple substrings
reader.search_multiple(
    [
        'short',
        'longer',
    ],
)
>>> ['some short string', 'another but now a longer string']

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Gal Ben David - gal@intsights.com

Project Link: https://github.com/Intsights/PySubstringSearch

Metadata

Release files for pysubstringsearch 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pysubstringsearch 0.7.1
File
pysubstringsearch-0.7.1-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
pysubstringsearch-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
pysubstringsearch-0.7.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
pysubstringsearch-0.7.1-cp311-cp311-macosx_10_7_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.7+ x86-64 Details
pysubstringsearch-0.7.1-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
pysubstringsearch-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
pysubstringsearch-0.7.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
pysubstringsearch-0.7.1-cp310-cp310-macosx_10_7_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.7+ x86-64 Details
pysubstringsearch-0.7.1-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
pysubstringsearch-0.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
pysubstringsearch-0.7.1-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
pysubstringsearch-0.7.1-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
pysubstringsearch-0.7.1-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
pysubstringsearch-0.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
pysubstringsearch-0.7.1-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details
pysubstringsearch-0.7.1-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
pysubstringsearch-0.7.1-cp37-none-win_amd64.whl CPython 3.7 none Windows x86-64 Details
pysubstringsearch-0.7.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
pysubstringsearch-0.7.1-cp37-cp37m-macosx_11_0_arm64.whl CPython 3.7 CPython 3.7 pymalloc macOS 11.0+ ARM64 Details
pysubstringsearch-0.7.1-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details

Total release size: 4.4 MB

Release files / pysubstringsearch-0.7.1-cp311-none-win_amd64.whl

Download URL pysubstringsearch-0.7.1-cp311-none-win_amd64.whl
Size 167.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
f996db385c528fd5bbf2a52e6e5bec82bf5f06fa79df65756075e93ec793c1eb
BLAKE2b-256 checksum
How to use checksums
78c26455efe5a9f129e07917b77135067d71b998f126dc1ee5cff2631bb72ff1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 266.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c8e41c9ddf2c5d234a17d1431c7c68fa804dbf1818529302a8bb74bc357692a1
BLAKE2b-256 checksum
How to use checksums
a97f2f750572a9c2a655caa1befe16acfa958dbf3aa8f41ad2e31ebed6e6e641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL pysubstringsearch-0.7.1-cp311-cp311-macosx_11_0_arm64.whl
Size 219.2 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
36461c4257e8a8208248b2f5ef6ce822e940fb7ed0c88f890f7b532c4d8f8b3d
BLAKE2b-256 checksum
How to use checksums
c91037dc4b35376bb42b5d087e63051ac937db7797d9823418510bc5b921f396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp311-cp311-macosx_10_7_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp311-cp311-macosx_10_7_x86_64.whl
Size 234.2 kB
Tags CPython 3.11 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
8afc514a716d59c6bed1318a2c4f7017c8c55abe20e22801d0c7f077ad946e51
BLAKE2b-256 checksum
How to use checksums
017f9c2c2ed7ae84576cd3f43174f1d4e9ce97fb7d8a8306ede74a254f99ab2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp310-none-win_amd64.whl

Download URL pysubstringsearch-0.7.1-cp310-none-win_amd64.whl
Size 167.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
85671c3282bce90f51d7de865c06d9300732123e72e29573007ee42098ab0cf8
BLAKE2b-256 checksum
How to use checksums
c0a0e6ef8d79397224735d10dec79357f925cee2758984c6b75ea3d1a9c40bc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 266.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
91acc31b4ef4cee7202e0d93870c9dd238666f6a622a566b0fcaac3e4d0c81f5
BLAKE2b-256 checksum
How to use checksums
5caa91e5432335641129a7b1068aebaf191aabee043fee8d39c69d3d8ec7b61d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL pysubstringsearch-0.7.1-cp310-cp310-macosx_11_0_arm64.whl
Size 219.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
afd3ea4663aba46b51c79029627a6407791417c47bd3dac2522f71c01b108641
BLAKE2b-256 checksum
How to use checksums
a2d4cc7a7b1c21b3075d898f240f67daa9109faad4c45fdde0cb498b480914db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp310-cp310-macosx_10_7_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp310-cp310-macosx_10_7_x86_64.whl
Size 234.1 kB
Tags CPython 3.10 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
e2ee2a3e2238964b8e24983ec2714daff22d08d40ea1ae4288deadf372a4d7af
BLAKE2b-256 checksum
How to use checksums
0a14e16e0d4c8ed147df6342bcdf594e997140880ec2dde1aebf4faf27415923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp39-none-win_amd64.whl

Download URL pysubstringsearch-0.7.1-cp39-none-win_amd64.whl
Size 167.3 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
f76d0c39eeccd28d301e100408f5b89cb399e1a305a9f011996cf699f5de5978
BLAKE2b-256 checksum
How to use checksums
6c9ca18388eeaa292949f3b0393c2e52a5f5d346ad331f2b96a0bb30e9c91726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 266.0 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a6490f7a5de76171442870f876af0f87a3a7e9fdb4bcc5e89913defa28cc4b02
BLAKE2b-256 checksum
How to use checksums
8170aea042a73ae1a23075dbf77feb07eac46c5425f4954970c9d7a1b6db92f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp39-cp39-macosx_11_0_arm64.whl

Download URL pysubstringsearch-0.7.1-cp39-cp39-macosx_11_0_arm64.whl
Size 219.4 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
55cf6549c9f3604b1663d0a89d4e53003ab5097364d0557cf87f607ec166b115
BLAKE2b-256 checksum
How to use checksums
1f2d04e15426dfc8bd4632bc4736930e4b950b95672f7bbe4fbd2209dd0bae52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp39-cp39-macosx_10_7_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp39-cp39-macosx_10_7_x86_64.whl
Size 234.4 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
a5b12cc74b2c74e93aaf83a4ab1435f396b63ffc4e784fc0c3ae1169ab8583b7
BLAKE2b-256 checksum
How to use checksums
93d4719f850005a7153dc4fd9766bf1f371e1f23e8ab6539e756cd79eba989e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp38-none-win_amd64.whl

Download URL pysubstringsearch-0.7.1-cp38-none-win_amd64.whl
Size 167.5 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
fe97bb077a672eab9875d8fb28023ea897cd1616ea5d1a81d44ed5d9743e2c62
BLAKE2b-256 checksum
How to use checksums
e58c31bef64c1bf29431459a17f7d495683f48e810a9f2fca8b8f47f0b111161
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 266.0 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
145ea03bc633332edb766c20a04882f045fd2109929c475e4b240bd9ea0fb3b8
BLAKE2b-256 checksum
How to use checksums
429ef9b62cb09823a2f51b6496373b6097c63c4ae863385e5bcdee86c47ab184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp38-cp38-macosx_11_0_arm64.whl

Download URL pysubstringsearch-0.7.1-cp38-cp38-macosx_11_0_arm64.whl
Size 219.1 kB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f91a8d05c982aa76b79b90b3120453f768df0a7a3fa66ee2353e9ac0851ad5b9
BLAKE2b-256 checksum
How to use checksums
5d3731de723861c62e7270bb796b4fed9fe7c4e2df73220a274014e1f83a79ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp38-cp38-macosx_10_7_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp38-cp38-macosx_10_7_x86_64.whl
Size 234.1 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
ede8582bef7db406bb4f673b610ccbbaeb93859db9f9d9feb142a0b200d61ab1
BLAKE2b-256 checksum
How to use checksums
8fc61971961a7250a064da0895eacf0a5efea0d3a410bd274d2a370fc544b57a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp37-none-win_amd64.whl

Download URL pysubstringsearch-0.7.1-cp37-none-win_amd64.whl
Size 167.5 kB
Tags CPython 3.7 Windows x86-64
SHA-256 checksum
How to use checksums
4077dd6fae7cb1b301ec105cf3e4a7f3a144f7f35003931e95dd7130664f1a5d
BLAKE2b-256 checksum
How to use checksums
0944b6a45ceeffdf9a58c9032cebc7d6c8e783a0011f76437609a04a84d7e09b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 266.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a96f8ab698c31d5eaa20b043f16b4747f31dd7a3faeb491474da3a47dc57ae92
BLAKE2b-256 checksum
How to use checksums
e865e9d9ab346fe6514a04fa0ba703e77171dc2d9de4f84108fa39e087822384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp37-cp37m-macosx_11_0_arm64.whl

Download URL pysubstringsearch-0.7.1-cp37-cp37m-macosx_11_0_arm64.whl
Size 219.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
897cd8fafb250ea8aa22188346a9ccebda5cb7676d5eadca11e42a9527ff9aed
BLAKE2b-256 checksum
How to use checksums
77cdee00185178515d7db9c82c663601935f9a383ae810022dd9534b7e0cf466
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release files / pysubstringsearch-0.7.1-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL pysubstringsearch-0.7.1-cp37-cp37m-macosx_10_7_x86_64.whl
Size 234.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
61aefe880f7b44ba825bf32b1769f43c553cbab1bebd61a5b8218728ec223286
BLAKE2b-256 checksum
How to use checksums
12470b26f96658f8cffaadabbc6fb82ae50c7b56fc3f486d4e1f9c8d49cd4da7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.20

Release history Release notifications | RSS feed

This release

0.7.1 This release

20 release files

0.7.0

15 release files

0.6.0

12 release files

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.0

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page