Navigate to the correct folder
cd /workspaces/esd-2024-jit-compiler/workshop/python/bytecode_conversion
python3 simple_calculator.py
See the output.
python3 -m py_compile simple_calculator.py
This will create a .pyc file in a directory named pycache.
python3 __pycache__/simple_calculator.cpython-312.pyc
fyi: 3.12 is the cpython version.
Is the output the same as running the .py file?
add in .py file on top:
import dis
and in the bottom of the .py file add:
dis.dis(SimpleCalculator)
Run the .py file again
python3 simple_calculator.py > output-python.txt
fyi: > is called 'output redirection'
Questions:
- Is the Python bytecode statically or dynamically typed?
- Is the Python bytecode (already) optimised by a JIT?
Compare the Python bytecode with the Java bytecode! Question: Name 2 differences.
Back to challenges overview