3 ms·
As other have pointed out elsewhere what matters here is not much the performance of the language but how much you can avoid calling IO code by making the path
by mrighele 9y ago
As other have pointed out elsewhere what matters here is not much the performance of the language but how much you can avoid calling IO code by making the path as straightforward as possible. You can get comparable performance ( 6.5 GB/s vs 8. GB/s on my machine) with 10 lines of python code, which probably took me the same time to write as the original rust version.
- e12e 9y agoI'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)