pythonstringdata-structurespython-3.xropes

Does Python have a rope data structure?


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.)


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.