Hi,

The following example shows that `wc -m` is even slower than the
equivalent Python code. Can this performance bug be fixed?

$ cat wcm.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:

import sys
l = 0
for line in sys.stdin:
    l += len(line.rstrip('\n').decode('utf-8'))
print l

$ time ./wcm.py < 1.txt
6786930

real    0m0.155s
user    0m0.059s
sys    0m0.048s
$ time wc -m < 1.txt
6796930

real    0m2.350s
user    0m2.280s
sys    0m0.017s

-- 
Regards,
Peng

Reply via email to