[PATCH 10 of 10] sshserver: avoid a multi-dot attribute lookup in a hot loop

Bryan O'Sullivan bos at serpentine.com
Thu Sep 13 14:01:23 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1347562631 25200
# Node ID 0858e1db71b831c35be5c1ffea4f0cca9b4d5af9
# Parent  2e017b25e1c9c13566990d601deafb24c2f665c5
sshserver: avoid a multi-dot attribute lookup in a hot loop

This improves stream_out performance by about 3%.

diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -71,8 +71,9 @@
         self.fout.flush()
 
     def sendstream(self, source):
+        write = self.fout.write
         for chunk in source.gen:
-            self.fout.write(chunk)
+            write(chunk)
         self.fout.flush()
 
     def sendpushresponse(self, rsp):


More information about the Mercurial-devel mailing list