A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-March/072326.html below:

[Python-Dev] Extended Buffer Interface/Protocol

[Python-Dev] Extended Buffer Interface/Protocol [Python-Dev] Extended Buffer Interface/ProtocolNeil Hodgson nyamatongwe at gmail.com
Sat Mar 24 07:08:06 CET 2007
   I have developed a split vector type that implements the buffer protocol at
http://scintilla.sourceforge.net/splitvector-1.0.zip

   It acts as a mutable string implementing most of the sequence
protocol as well as the buffer protocol. splitvector.SplitVector('c')
creates a vector containing 8 bit characters and
splitvector.SplitVector('u') is for Unicode.

   A writable attribute bufferAppearence can be set to 0 (default) to
respond to buffer protocol calls by moving the gap to the end and
returning the address of all of the data. Setting bufferAppearence to
1 responds as a two segment buffer. I haven't found any code that
understands responding with two segments. sre and file.write handle
SplitVector fine when it responds as a single segment:

import re, splitvector
x = splitvector.SplitVector("c")
x[:] = "The life of brian"
r = re.compile("l[a-z]*", re.M)
print x
y = r.search(x)
print y.group(0)
x.bufferAppearence = 1
y = r.search(x)
print y.group(0)

   produces

The life of brian
life
Traceback (most recent call last):
  File "qt.py", line 9, in <module>
    y = r.search(x)
TypeError: expected string or buffer

   It is likely that adding multi-segment ability to sre would
complexify and slow it down. OTOH multi-segment buffers may be
well-suited to scatter/gather I/O calls like writev.

   Neil
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4