I am trying to convert my perl one-liners to pyp. My first attempt was given to me kindly as the answer to another question as
pyp "mm | p if n==0 else (p[:-2] + [(int(x)%12) for x in p[-2:]]) | mm"
However this turns out to be amazingly slow. If I create a test file using
for j in xrange(50000):
print ",".join(str(i) for i in [random.choice(xrange(1000)) for i in xrange(8)])
and then run
time (cat testmedium.txt |~/.local/bin/pyp "mm | p if n==0 else (p[:-2] + [(int(x)%12) for x in p[-2:]]) | mm" > /dev/null)
I get
real 1m27.889s
user 1m26.941s
sys 0m0.688s
However the equivalent in perl is almost instant.
time (cat testmedium.txt |perl -l -a -F',' -p -e'if ($. > 1) { $F[6] %=12; $F[7] %= 12;$_ = join(q{,}, @F[6,7]) }' > /dev/null)
real 0m0.196s
user 0m0.192s
sys 0m0.012s
For larger test files the difference is even more dramatic.