[Python-Dev] Deprecate the buffer object?
Troels Walsted Hansen
troels at thule.no
Wed Oct 29 02:57:19 EST 2003
Raymond Hettinger wrote:
> At least the builtin buffer function should go away.
> Even if someone had a use for it, it would not make-up for all the time
> lost by all the other people trying to figure what it was good for.
I trust you will preserve the functionality though?
I have used the buffer() function to achieve great leaps in performance
in applications which send data from a string buffer to a socket.
Slicing kills performance in this scenario once buffer sizes get beyond
a few 100 kB.
Below is example from an asyncore.dispatcher subclass. This code sends
chunks with maximum size, without ever slicing the buffer.
def handle_write(self):
if self.buffer_offset:
sent = self.send(buffer(self.buffer, self.buffer_offset))
else:
sent = self.send(self.buffer)
self.buffer_offset += sent
if self.buffer_offset == len(self.buffer):
del self.buffer
Troels
More information about the Python-Dev
mailing list