python 3 subprocess performance

Konstantin Schukraft konstantin at schukraft.org
Thu Apr 11 14:04:48 UTC 2019


Hi,

>I've noticed the subprocess performance issue with python 3.
>For example, this simple script takes just 0,15 second to complete
>with python 2.7, but more than 5 sec with python 3.6:
>
>import subprocess
>
>for i in range(100):
>    p = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>    (stdoutdata, stderrdata) = p.communicate()
>
>Profiling with the cProfile shows, that this excessive 5 seconds was
>wasted in the "{built-in method posix.read}"
>
>Could anybody confirm this issue?

I see this on HardenedBSD 12 with python2.7 (fast) and python3.6 and 3.7
(both slow) installed from packages.
Interestingly, I don't see this on my FreeNAS 11.3, where python2.7 and
3.6 are both installed by default and run fast.


Hope that helps,

Konstantin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20190411/daa05909/attachment.sig>


More information about the freebsd-ports mailing list