Hello, On Sun, May 13, 2018 at 09:05:47AM -0400, Peng Yu wrote: > I am on Mac not on Linux. On Linux, I can confirm that `wc -m` is much > faster than `wcm.py`.
As a first step, please run "wc --version" to confirm you are using gnu coreutils' wc and not the macos native wc program. > Here is the output on Mac. > > $ seq 1000000 > num.txt > $ time wc -m < num.txt > 6888896 > > real 0m2.751s > user 0m2.622s > sys 0m0.042s > $ time ./wcm.py < num.txt > 6888896 > > real 0m1.401s > user 0m1.234s > sys 0m0.051s Assuming it is coreutils' wc, I suspect file caching still plays a significant role here. Can you try: seq 1000000 | time wc -m seq 1000000 | time ./wcm.py And report the timing ? regards, - assaf
