4 ms·
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 =
by jdnier 9y ago
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.
https://docs.python.org/3/library/sys.html https://docs.python.org/3/library/sys.html