bytegapbuffer: gap buffer backed bytearray class for Python
A Python bytearray work alike which uses a gap buffer as underlying storage. It is a data structure optimised for locally coherent insertions and deletions. It is the usual data structure in text editors.
A utility class, codedstring, is provided which provides a string-like view on a bytegapbuffer transparently encodes and decodes Unicode strings. It provides efficient common-case indexing.
Installation
Installation is via pip. To install the latest release version:
$ pip install bytegapbuffer
To install the current development version from git:
$ pip install git+https://github.com/rjw57/bytegapbuffer
Usage
The bytegapbuffer collection aims to behave just like a bytearray. For example:
from bytegapbuffer import bytegapbuffer
a = bytegapbuffer(b'hello')
a.insert(3, 65)
a.insert(4, 66)
assert a == b'helABlo'
Status
This project is used as part of a personal project of mine and, as such, implements just enough of the sequence, mutable sequence and bytearray interface for my needs. Pull requests adding missing functionality are welcome. Please also add a test for the functionality.
Current features:
Retrieving element(s) via [i], [i:j] and [i:j:k] style slicing.
Deletion of element(s) via [i], [i:j] style slicing.
Insertion/replacement of element(s) via [i], [i:j] style slicing.
Insertion of element via insert().
Length query via len().
Sub-sequence search via index() and find() methods.
Equality (and inequality) testing.
Iteration over contents.
Efficient codedstring wrapper allowing bytegapbuffer to be used as underlying storage in a text editor.
All of the above should work exactly as the bytearray object does. (This is tested in the test suite.) Additional non-bytearray features:
Deep copying via copy() method.
Test suite
The test suite may be run via the tox utility. The Travis builds are set up to run the test suite on the latest released Python 2 and Python 3 versions.
Licence
Copyright (C) 2015 Rich Wareham
This code is licensed under a BSD-style licence. See the LICENSE file for details.
Metadata
Release files for bytegapbuffer 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bytegapbuffer-0.9.4.tar.gz | 11.0 kB | Without provenance | Details for bytegapbuffer-0.9.4.tar.gz |
Release files / bytegapbuffer-0.9.4.tar.gz
| Download URL | bytegapbuffer-0.9.4.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54889a4e1eb0bf17dacee894a970957fb19e3942c9ac41d3f4840e78eca527da
|
|
BLAKE2b-256 checksum How to use checksums |
87c8e5b6adb502f2cc82d119de09fbae4d13f773e9ad1a166832ee76cef880bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bytegapbuffer 0.9.4
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.