| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # ./compare.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | readonly PY27=~/src/Python-2.7.6
|
| 11 | readonly PY36=~/src/Python-3.6.1
|
| 12 |
|
| 13 | readonly DIFF=${DIFF:-diff -u}
|
| 14 |
|
| 15 | ceval() {
|
| 16 | # 4900 lines vs 5500 lines. Wow
|
| 17 | wc -l {$PY27,$PY36}/Python/ceval.c
|
| 18 | return
|
| 19 | $DIFF {$PY27,$PY36}/Python/ceval.c
|
| 20 | }
|
| 21 |
|
| 22 | ccompile() {
|
| 23 | # 4000 vs 5300 lines. Big increase. But it depends on the opcodes.
|
| 24 | wc -l {$PY27,$PY36}/Python/compile.c
|
| 25 | }
|
| 26 |
|
| 27 | opcodes() {
|
| 28 | #cp -v $PY27/Lib/opcode.py _tmp/opcode27.py
|
| 29 | #cp -v $PY36/Lib/opcode.py _tmp/opcode36.py
|
| 30 |
|
| 31 | $DIFF _tmp/opcode{27,36}.py
|
| 32 | return
|
| 33 |
|
| 34 | cp $PY27/Lib/dis.py _tmp/dis27.py
|
| 35 | cp $PY36/Lib/dis.py _tmp/dis36.py
|
| 36 |
|
| 37 | $DIFF _tmp/dis{27,36}.py
|
| 38 | }
|
| 39 |
|
| 40 | 2to3-grammar() {
|
| 41 | # The compiler package was written for a different grammar!
|
| 42 | $DIFF $PY27/Grammar/Grammar 2to3.grammar
|
| 43 | }
|
| 44 |
|
| 45 | # pgen2 has BACKQUOTE = 25. No main.
|
| 46 | tokens() {
|
| 47 | $DIFF token.py pgen2/token.py
|
| 48 | }
|
| 49 |
|
| 50 | # This is very different -- is it Python 2 vs. Python 3?
|
| 51 | tokenize() {
|
| 52 | $DIFF tokenize.py pgen2/tokenize.py
|
| 53 | }
|
| 54 |
|
| 55 | compiler2() {
|
| 56 | #diff -u $PY27/Lib/compiler/ compiler2
|
| 57 |
|
| 58 | # The version we're actually running
|
| 59 | diff -u /usr/lib/python2.7/compiler/ compiler2
|
| 60 | }
|
| 61 |
|
| 62 | compiler26-27() {
|
| 63 | diff -u ~/src/Python-2.{6,7}.9/Lib/compiler/
|
| 64 | }
|
| 65 |
|
| 66 | compiler27() {
|
| 67 | diff -u ~/src/Python-2.7.{2,9}/Lib/compiler/
|
| 68 | }
|
| 69 |
|
| 70 | set27() {
|
| 71 | diff -u ~/src/Python-2.7.{2,3}/Objects/setobject.c
|
| 72 | }
|
| 73 |
|
| 74 | if test $(basename $0) = compare.sh; then
|
| 75 | "$@"
|
| 76 | fi
|