Created
May 29, 2023 18:36
-
-
Save Hermann-SW/a7431aff0022f9ee81f3cf3fa6c7a480 to your computer and use it in GitHub Desktop.
Short demo of using Cython, setting language_level, compare runtimes, ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pip install setuptools Cython gmpy2 | |
rm -rf /tmp/tst && mkdir /tmp/tst && cd /tmp/tst | |
wget -q https://gist.githubusercontent.com/Hermann-SW/061d33b47325bd15a4033b33d3f7c4c9/raw/9900616d98b6acdd50c436d9ae914a1c5d81f2b2/sq2_cg.py | |
mv sq2_cg.py sq2_cg.pyx | |
cat << EOF > setup.py | |
from setuptools import setup | |
from Cython.Build import cythonize | |
setup( ext_modules = cythonize("sq2_cg.pyx", language_level=3) ) | |
EOF | |
python setup.py build_ext --inplace > log | |
echo "import sq2_cg" > import.py | |
echo -n "sq2_cg.pyx: " && python sq2_cg.pyx > out | |
echo -n "import.py: " && python import.py > out2 | |
echo "diff:" && diff out out2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://forums.raspberrypi.com/viewtopic.php?t=352039