by asifgdinio · 6y ago · 0 comments
This is off by at least three orders of magnitude, at least on my machine.
$ time for i in $(seq 1000000); do true; done
real 0m1.049s
user 0m1.037s
sys 0m0.019s
This article would be better if it were about computers in general, not about Python. I specifically avoid using Python for anything serious because I find its performance impossible to reason about. Then again, perhaps it's a good thing to have examples that require thinking rather than just reciting the machine's specs like most of these lists I've seen.1. Use the external "true" command.
2. Use {a..b} to expand sequences of numbers as "seq" adds extra overhead.
$ time for i in {1..500}; do /bin/true; done
real 0m0.983s
user 0m0.650s
sys 0m0.423s