Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Le jeudi 31 juillet 2008 à 00:00 +0000, Amaury Forgeot d'Arc a écrit : > Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: > > > If it was rewritten to use a fixed-size bytearray > does such an object exist today?
Manually, yes :) Just preallocate your bytearray, e.g.: b = bytearray(b" " * 4096) and then be careful to only do operations (e.g. slice assignments) which keep the size intact. In a BufferedWriter implementation, you would have to keep track of the currently used chunk in the bytearray (offset and size). Anyway, I'd question the efficiency of the bytearray approach; when removing the quadratic behaviour in BufferedReader I discovered that using a bytearray was slower than keeping a list of bytes instances and joining them when needed (not to mention that the latter is inherently thread-safe :-)). The reason is that the underlying raw stream expects and returns bytes, and the public buffered API also does, so using a bytearray internally means lots of additional memory copies. (a related problem is that readinto() does not let you specify an offset inside the given buffer object, it always starts writing at the beginning of the buffer. Perhaps memoryview() will support creating subbuffers, I don't know...) _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3139> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com