Skip to main content

String algorithms

Project description

PyPI version Build Status

pydivsufsort: bindings to libdivsufsort

pydivsufsort prebuilds libdivsufsort as a shared library and includes it in a Python package with bindings.

Features:

  • bindings to divsufsort that return numpy arrays
  • handle almost any integer data type (e.g. int64) and not only char
  • additional string algorithms

Installation

On Linux, macOS and Windows:

python -m pip install pydivsufsort

We provide precompiled wheels for common systems, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue.

Usage

from pydivsufsort import divsufsort, kasai

print(divsufsort(b"abcd"))

inp = np.array([1, 4, 2, 4, 5, 2, 2])
sa = divsufsort(inp)
print(kasai(inp, sa))

Testing

pytest

Technical details (for performance tweaks)

libdivsufsort is compiled in both 32 and 64 bits, as the 32 bits version is faster. pydivsufsort automatically chooses to use the 32 bits version when possible (aka when the input size is less than 2**31-1).

The precompiled libraries use OpenMP. You can disable it by setting the env variable OMP_NUM_THREADS=1, and it will yield the same performance as the version compiled without OpenMP

The original libdivsufsort only supports char as the base type. pydivsufsort can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, pydivsufsort will automatically change their type (see #6).

Acknowledgements

Project details


Download files

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

Files for pydivsufsort, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pydivsufsort-0.0.3-cp36-cp36m-macosx_10_13_x86_64.whl (172.7 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp36-cp36m-manylinux2010_i686.whl (534.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp36-cp36m-manylinux2010_x86_64.whl (674.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp36-cp36m-win32.whl (129.0 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp36-cp36m-win_amd64.whl (160.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp37-cp37m-macosx_10_13_x86_64.whl (173.3 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp37-cp37m-manylinux2010_i686.whl (536.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp37-cp37m-manylinux2010_x86_64.whl (674.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp37-cp37m-win32.whl (128.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp37-cp37m-win_amd64.whl (160.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp38-cp38-macosx_10_13_x86_64.whl (174.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp38-cp38-manylinux2010_i686.whl (612.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp38-cp38-manylinux2010_x86_64.whl (771.7 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp38-cp38-win32.whl (130.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pydivsufsort-0.0.3-cp38-cp38-win_amd64.whl (162.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pydivsufsort-0.0.3.tar.gz (182.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page