[Python-checkins] cpython (merge 3.3 -> default): Fixes issue #19929: Call os.read with 32768 within subprocess.Popen

gregory.p.smith python-checkins at python.org
Sun Dec 8 19:58:41 CET 2013


http://hg.python.org/cpython/rev/4de4b5a4e405
changeset:   87839:4de4b5a4e405
parent:      87837:0f587fe304be
parent:      87838:03a056c3b88e
user:        Gregory P. Smith <greg at krypto.org>
date:        Sun Dec 08 10:58:28 2013 -0800
summary:
  Fixes issue #19929: Call os.read with 32768 within subprocess.Popen
communicate rather than 4096 for efficiency.  A microbenchmark shows
Linux and OS X both using ~50% less cpu time this way.

files:
  Lib/subprocess.py |  2 +-
  Misc/NEWS         |  4 ++++
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1601,7 +1601,7 @@
                                     selector.unregister(key.fileobj)
                                     key.fileobj.close()
                         elif key.fileobj in (self.stdout, self.stderr):
-                            data = os.read(key.fd, 4096)
+                            data = os.read(key.fd, 32768)
                             if not data:
                                 selector.unregister(key.fileobj)
                                 key.fileobj.close()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,10 @@
 - Issue #19343: Expose FreeBSD-specific APIs in resource module.  Original
   patch by Koobs.
 
+- Issue #19929: Call os.read with 32768 within subprocess.Popen.communicate
+  rather than 4096 for efficiency.  A microbenchmark shows Linux and OS X
+  both using ~50% less cpu time this way.
+
 - Issue #19506: Use a memoryview to avoid a data copy when piping data
   to stdin within subprocess.Popen.communicate.  5-10% less cpu usage.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list