On Wednesday 28 Aug 2002 2:19 pm, Jeremy Hylton wrote:
I'd like to change this bit of code in handle_write():
if n < len(v): # XXX It's unfortunate that we end up making many # slices of a large string. output.insert(0, v[n:]) break # we can't write any more
If we send a very large message, which could be caused by a big pickle or just a transaction that touches a lot of objects, the message gets sent in little chunks. The current implementation uses string slicing to save the rest of the string, but that ends up making many copies of the large string -- an O(n^2) proposition.
A possible solution is to store an index into the first string in __output and just increment the index. The logic will be a bit tricky to get right.
There is an O(n) option with easy logic... fragment big strings inside message_output. diff attached. [hmmm. Its use of a python list as a fifo queue is O(n2) worst case, but I doubt we will be affected by that in practice]