different string representation (buffer gap)

Michael Spencer michael at telcopartners.com
Wed Feb 11 20:25:43 CET 2004

"manders2k" <manders2k_NOSPAM at yahoo.com> wrote in message

> What I guess I wish were the case is that I could implement the
> "string interface" on my BufferGap, so that everywhere that Python (at
> the C API level) expects a string, a BufferGap could be used instead.
> That way, all the libraries that inspect and operate on strings would
> work transparently, without having to be recoded (copy / paste, end up
> with a lot of mostly identical, redundant code) to operate on this
> other string representation.  Maybe this just isn't possible with the
> current C-Python implementation.

Have you looked at the mmap standard module?
"Memory-mapped file objects behave like both strings and like file objects.
Unlike normal string objects, however, these are mutable. You can use mmap
objects in most places where strings are expected; for example, you can use
the re module to search through a memory-mapped file"


More information about the Python-list mailing list