Skip to main content

sufarray: implementation of suffix array

It uses prefix doubling for calculating the suffix array, which is O(n log n) time. When searching for all occurrences of a string, it takes O(log n) time. Further occurrences takes constant time.

At present the implementation is Python only. This has the drawback that the speed is not comparable with those of other languages.

Usage

To construct a suffix array of string s:

import sufarray
sarray = sufarray.SufArray(s)

After that, you can get the actual array with:

sarray.get_array()

This produces a permutation a of range(len(s)), where the values a[0], a[1], etc. are such that the suffixes s[a[i]:] is sorted.

Other than that, you can find the positions where a string n appears within s using:

sarray.find_all(n)

This is a generator function, yielding all the possible positions.

Implementations

Two implementations are provided. The simple version is called SufArrayBruteForce, and a version SufArrayPD is provided which calculates the suffix array using prefix doubling, and augment the result with a LCP (Longest common prefix) array for use with searching. The latter has better bounded performance guarantees, but with arrays of small text it is slower. The default is SufArrayPD. You can use the brute force version using sufarray.SufArrayBruteForce.

Metadata

Release files for sufarray-kkto 0.1.1

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

Source distribution (sdist)

Source distribution for sufarray-kkto 0.1.1
File Size Uploaded Provenance
sufarray_kkto-0.1.1.tar.gz 5.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sufarray-kkto 0.1.1
File Interpreter ABI Platform
sufarray_kkto-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / sufarray_kkto-0.1.1.tar.gz

Download URL sufarray_kkto-0.1.1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7705aa9b6ee6fc36bad4f8a725fa77d1468e85e5688f74574a447cee14ca80c0
BLAKE2b-256 checksum
How to use checksums
a703f4393512c543a46d56b2c9e76f5ca177e82f68d8d05497fdd9533ef3efea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.5.3

Release files / sufarray_kkto-0.1.1-py3-none-any.whl

Download URL sufarray_kkto-0.1.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07b689566ce3e0448318d21b27a97340aa2decf1a254bbae3805613283a7422f
BLAKE2b-256 checksum
How to use checksums
dab72dfdbf65d52ce6ee0186df5ab358743321903d1b99c95d151e074f6f215f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.5.3

Security for sufarray-kkto 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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