I want to create a python class that represents a string, but can be modified efficiently. I thought about implementing a treelike data structure, but I don't know how to make it behave like a string, such that it can be used in all kind of string functions, for instance in regular expressions.
Of course one could construct a string from the data structure each time it is needed, but that isn't very efficient, and wastes the efficiency of the data structure.
Any ideas?
I think one needs to implement both "sequence" and "buffer" Python protocols, which are only available from C. There is one library I know about which does this, though it's a bit dated:
https://code.google.com/p/gapbuffer/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With