[issue39150] See if PyToken_OneChar would be faster as a lookup table

Andy Lester report at bugs.python.org
Thu Jan 9 10:09:29 EST 2020


Andy Lester <andy at petdance.com> added the comment:

Yes, I ran it multiple times on my 2013 Macbook Pro and got ~10% speedup.  I also ran it on my Linux VM (that I only use for development) and got a speedup but less so.

The code I used to run the tests is at: https://github.com/petdance/cpython/blob/Issue39150/timetests

LOG=timelog.txt
NRUNS=100
NFILES=100

if [ -x ./python.exe ] ; then
    PYTHON=./python.exe
else
    PYTHON=./python
fi

# Build a file list, but throw out some that have syntax errors.
# Use the 100 biggest files.
FILES=$(
    find . -name '*.py' -type f -ls \
    | grep -v Tools/test2to3/ \
    | grep -v Lib/lib2to3/tests/ \
    | grep -v Lib/test/badsyntax \
    | grep -v Lib/test/bad_coding \
    | sort -r -n -k7 \
    | awk '{print $11}' \
    | head -n $NFILES
)

echo "Compiling $NFILES files for $NRUNS iterations"

rm -f $LOG

for (( i=1; i<=$NRUNS; i++ )) do
    echo "Run $i"
    { time $PYTHON -m py_compile $FILES; } >> $LOG 2>&1
done

perl -ne'if(/real\s+0m([\d.]+)s/){$t+=$1;$n++} END { printf "%d runs, average %0.4f\n", $n, $t/$n}' $LOG

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39150>
_______________________________________


More information about the Python-bugs-list mailing list