4 ms·
The code is below. I have to admit that after a few more test I realized that the performance greatly depends on the length of the input, in some cases going a
by mrighele 9y ago
The code is below.
I have to admit that after a few more test I realized that the performance greatly depends on the length of the input, in some cases going as low 2 GB/s and some others reaching the performance of the GNU yes installed on my system. This is probably due to the fact that I build the buffer in a quite naive way.
With a bit more work maybe that can be fixed.
#!/usr/bin/python
import sys
yes = "yes\n"
print(sys.argv)
if len(sys.argv) == 2:
yes = sys.argv[1] + "\n"
size = 4096
buf = bytes(yes * size, 'utf-8')
while True:
sys.stdout.buffer.write(buf)