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.)
Does Python have a rope data structure?
Asked Answered
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.
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)
© 2022 - 2024 — McMap. All rights reserved.