2 ms·
I'm sure a lot of people would like to see the code for comparison. I know I would.
by e12e 9y ago
I'm sure a lot of people would like to see the code for comparison. I know I would.
- mrighele 9y agoThe 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)