[Python-Dev] Deprecate the buffer object?
Jp Calderone
exarkun at intarweb.us
Thu Oct 30 19:21:51 EST 2003
On Wed, Oct 29, 2003 at 08:57:19AM +0100, Troels Walsted Hansen wrote:
> 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
>
Twisted uses buffer() similarly. It originally sliced, by a company using
the library complained of performance problems. Switching to buffer()
alleviated those problems.
Jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/python-dev/attachments/20031030/15556250/attachment.bin
More information about the Python-Dev
mailing list