ropey.RopeBuilder

class ropey.RopeBuilder

An efficient incremental Rope builder.

This is used to efficiently build ropes from sequences of text chunks. It is useful for creating ropes from:
  • …large text files, without pre-loading their entire contents into memory (but see from_reader() for a convenience function that does this for casual use-cases).

  • …streaming data sources.

  • …non-utf8 text data, doing the encoding conversion incrementally as you go.

Unlike repeatedly calling Rope::insert() on the end of a rope, this API runs in time linear to the amount of data fed to it, and is overall much faster.

Methods

append(chunk, /)

Appends chunk to the end of the in-progress Rope.

finish

Finishes the build, and returns the Rope.

append(chunk, /)

Appends chunk to the end of the in-progress Rope.

Parameters

chunk (str) – chunk

finish()

Finishes the build, and returns the Rope.

Returns

Rope Rope