Skip to main content

Ropes

Early implementation of a Rope data structure in Python.

About ropes

Ropes are an mutable alternative to strings. The string is represented as a binary tree, and modifications to the string are achieved by either replacing existing substring branches or by inserting new substrings into the tree structure.

This is a preliminary version which supports the basic operations, such as concatentation, indexing, slices, and strides.

Implementation of some features is currently poor, particularly the slicing operations. No effort is made to balance the tree or otherwise optimise the data structure.

Usage

To convert a string into a rope, use the Rope class constructor.

r = Rope('abcdefg')

A pre-defined Rope tree can be constructed using a list of strings.

r = Rope(['abc', 'def', 'g'])

Printing the rope returns a string.

>>> r = Rope(['abc', 'defg'])
>>> r
(Rope('abcd') + Rope('efg'))
>>> print(r)
abcdefg

Strings can be inserted between existing ropes.

>>> r, s = Rope('abc'), Rope('def')
>>> u = '123'
>>> r + u + s
((Rope('abc') + Rope('123')) + Rope('def'))
>>> print(r + u + s)
abc123def
>>>

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

Metadata

Release files for ropes 0.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 ropes 0.1
File Size Uploaded
ropes-0.1.tar.gz 5.0 kB Details

Release files / ropes-0.1.tar.gz

Download URL ropes-0.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f0bbc3a75d24b6a8048967bf2468d6577c2878d9257822e6a6df7ba5379f1670
BLAKE2b-256 checksum
How to use checksums
26ff4cdd9ff5950e07de6c60a03fec52c583f72a10c4967a79fa07d859faeb9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1 This release

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