Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Unified Diff: Lib/subprocess.py

Issue 19506: subprocess.communicate() should use a memoryview
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/subprocess.py Wed Nov 20 12:49:05 2013 +0100
+++ b/Lib/subprocess.py Wed Nov 20 14:58:08 2013 +0100
@@ -1555,6 +1555,10 @@ class Popen(object):
self._save_input(input)
+ # use a memoryview to avoid memory copies
+ if input:
+ input_view = memoryview(self._input)
+
with _PopenSelector() as selector:
if self.stdin and input:
selector.register(self.stdin, selectors.EVENT_WRITE)
@@ -1576,8 +1580,8 @@ class Popen(object):
for key, events in ready:
if key.fileobj is self.stdin:
- chunk = self._input[self._input_offset :
- self._input_offset + _PIPE_BUF]
+ chunk = input_view[self._input_offset :
+ self._input_offset + _PIPE_BUF]
try:
self._input_offset += os.write(key.fd, chunk)
except OSError as e:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+