mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Fixes issue #19506: Use a memoryview to avoid a data copy when piping data
to stdin within subprocess.Popen.communicate. 5-10% less cpu usage.
This commit is contained in:
parent
6c527cf37f
commit
774f909489
2 changed files with 8 additions and 2 deletions
|
|
@ -1621,6 +1621,9 @@ class Popen(object):
|
||||||
|
|
||||||
self._save_input(input)
|
self._save_input(input)
|
||||||
|
|
||||||
|
if self._input:
|
||||||
|
input_view = memoryview(self._input)
|
||||||
|
|
||||||
while self._fd2file:
|
while self._fd2file:
|
||||||
timeout = self._remaining_time(endtime)
|
timeout = self._remaining_time(endtime)
|
||||||
if timeout is not None and timeout < 0:
|
if timeout is not None and timeout < 0:
|
||||||
|
|
@ -1638,7 +1641,7 @@ class Popen(object):
|
||||||
|
|
||||||
for fd, mode in ready:
|
for fd, mode in ready:
|
||||||
if mode & select.POLLOUT:
|
if mode & select.POLLOUT:
|
||||||
chunk = self._input[self._input_offset :
|
chunk = input_view[self._input_offset :
|
||||||
self._input_offset + _PIPE_BUF]
|
self._input_offset + _PIPE_BUF]
|
||||||
try:
|
try:
|
||||||
self._input_offset += os.write(fd, chunk)
|
self._input_offset += os.write(fd, chunk)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #19506: Use a memoryview to avoid a data copy when piping data
|
||||||
|
to stdin within subprocess.Popen.communicate. 5-10% less cpu usage.
|
||||||
|
|
||||||
- Issue #19839: Fix regression in bz2 module's handling of non-bzip2 data at
|
- Issue #19839: Fix regression in bz2 module's handling of non-bzip2 data at
|
||||||
EOF, and analogous bug in lzma module.
|
EOF, and analogous bug in lzma module.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue