4 ms·
For a program like this, execution is I/O bound rather than CPU bound, so even if Python is generally less CPU efficient than Rust the effect is overwhelmed by
by kibwen 9y ago
For a program like this, execution is I/O bound rather than CPU bound, so even if Python is generally less CPU efficient than Rust the effect is overwhelmed by a different I/O strategy. It's just like how Node has greater max throughput for trivial server workloads than a naive C implementation.
- katastic 9y agoThat doesn't make a whole lot of sense when the guy above you posted that two versions of python (2 vs 3) have significantly different output throughput rates. If it's I/O bound why are they changing at all?
- benaiah 9y agoIt is I/O bound, but Python 2 and 3 do I/O differently. From the same comment that you're referring to: > Python 2 emits writes of 4096 bytes, and python 3... 8193 bytes (edit: not a typo, this is 8KiB + 1).
- coldtea 9y ago>If it's I/O bound why are they changing at all? Who said I/O functions didn't change between Python2 and Python3?
- glandium 9y agoAccording to empirical evidence in my sibling post, that's not true in this case.
- benaiah 9y agoYour post seems to demonstrate _exactly_ what the post you're replying to is saying: most of the speed has to do with I/O strategy (buffering and syscall usage), not the actual speed of the involved language. Maybe I'm missing a distinction you're making, but I'm not following how your previous comment leads to what you're saying here.
- glandium 9y agoThe rust version that does exactly what python does (buffered output) is an order of magnitude faster (even if I force the rust buffer size to be 4KiB like with python2).
- kibwen 9y agoTo head off this comment chain, I've softened the language in my original comment to "overwhelmed by" rather than implying that non-I/O factors are wholly irrelevant. :)