Skip to main content

A Python implementation of the piece table data structure

Project description

piece-table on TravisCI piece-table on PyPI MIT License badge

About piece_table

Early implementation of the piece table data structure in Python.

A piece table is an efficient data structure to represent a series of edits to a text document. A more detailed discussion can be found here. Inspired by the JavaScript implementation.

Installation

To install the package, run the following:

pip install piece-table

Usage

Current usage is very basic, but will hopefully improve in the future.

Basic use is demonstrated below.

from piece_table import PieceTable

document = PieceTable("Initialize a document with some text.")

document.insert("Add some text to the start of the document. ", 0)

# Delete the inserted text
document.delete(0, 44)

text_sequence = document.get_text()
# text_sequence == "Initialize a document with some text."

sub_string = document[13:21]
# sub_string == "document"

Testing

To test the package, run the following:

python -m unittest discover -s tests

Project details


Download files

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

Source Distribution

piece_table-0.0.3.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file piece_table-0.0.3.tar.gz.

File metadata

  • Download URL: piece_table-0.0.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

File hashes

Hashes for piece_table-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e3a7b7407585d54f0ab39f43e187539553b0453e4cd2fef60fbd41a53838123d
MD5 0665b4ea75aada9a3d1db73516fefa6f
BLAKE2b-256 e010254dbb7817803637b3ccf2e05ca7a7d9cedd58a0fb33f7222279da653008

See more details on using hashes here.

Supported by

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