Re:A Little Story About the `yes` Unix Command
by jdnier on Wednesday October 11, 2017 @11:41PM
(#15455502)
On my Macbook with way too much running, I get about 800MiB/s in Python2 with your script, but 1.12GiB/s with this Python3 script:
import sys
s = b'y\n' * 1024
write = sys.stdout.buffer.write
while True:
write(s)
# 1.12GiB/s
Plain old yes comes in at 22Mib/s.The Python3 docs say to "use the underlying binary buffer object" when reading or writing binary data.
(had to separate the asters to stop HN swallowing them)
Plain old `yes` gets a measly 33Mb/s!!