[python-users] Transpiler

Christopher Arndt chris at chrisarndt.de
So Feb 9 19:07:09 CET 2014


On 09.02.2014 18:22, Christopher Arndt wrote:
> timefib.py:
> 
>     import time
>     import pyximport; pyximport.install()
>     import fib
>     [...]

Ein nette Alternative zu pyximport ist folgende Bash-Funktion:

pyxrun() {
    bn="${1%.*}"

    if [ ! -x "$bn" -o "$1" -nt "$bn" ]; then
        cython --embed "$1"
        gcc -o "$bn" "$bn.c" `python-config --cflags --ldflags`
    fi

    "`dirname $1`/${bn##*/}"
}


$ pyxrun fib.pyx


Wobei dann die fib.pyx einen 'if __name__ == '__main__':' Block haben
sollte.


Chris



Mehr Informationen über die Mailingliste python-users