$ wc --version wc (GNU coreutils) 8.29 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Written by Paul Rubin and David MacKenzie. $ seq 1000000 | time wc -m 6888896 2.69 real 2.52 user 0.03 sys $ seq 1000000 | time ./wcm.py 6888896 1.30 real 1.18 user 0.04 sys On Sun, May 13, 2018 at 12:54 PM, Assaf Gordon <assafgor...@gmail.com> wrote: > 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 -- Regards, Peng