Question

In writing some Python code, I came upon a need for a string-like data structure that offers fast insertion into, access to, and deletion from arbitrary positions. The first data structure that came to mind was a rope. Does Python have a rope data structure already implemented somewhere? I've looked through the standard library and PyPI, but I haven't seen one. (It doesn't help that there's a refactoring library for Python by the name of Rope as well as a company called Python Rope that sells wire rope.)

Was it helpful?

Solution

There isn't one in the standard library, but there are implementations out there, e.g. pyropes.


There's also this list of various non-built-in data structure implementations for Python.

OTHER TIPS

Yes! there is one package available at PyPI.org for Rope data structure(named pyropes), written purely in Python 3. You can install it using

pip install pyropes

It also have full documentation on how to use it. Though it requires Python >=3.6(because it uses f-strings)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top