[MERGE] Re: [Bug 115781] Re: traceback on smart server when branching/pulling (win32)
Alexander Belchenko
bialix at ukr.net
Tue Dec 18 14:52:15 GMT 2007
bb:approve
Andrew Bennetts пишет:
> [moving discussion to list so that people can review the code]
> Sending to the list for feedback.
>
> It's probably better to write the loop as:
>
> chunk_size = 2**16
> pos = 0
> while pos < len(bytes):
> chunk = bytes[pos:pos+chunk_size]
> pos += chunk_size
> self.socket.sendall(chunk)
>
> This way we avoid copying multi-megabyte strings in memory repeatedly.
>
> Attached is the patch for review. It has the improved loop, a comment, and a
> NEWS entry. See https://bugs.launchpad.net/bzr/+bug/115781 for the complete
> discussion about the problem.
As another improvements you could use for loop,
chunk_size = 2**16
for pos in xrange(0, len(bytes), chunk_size):
self.socket.sendall(bytes[pos:pos+chunk_size])
but *your* variant actually is OK for me, it's just an example.
I don't know is for loop better/readable here.
> Alexander, thanks for testing the patches!
Yeah, in the end, I'm interested party.
More information about the bazaar
mailing list