Why is it impossible to create a compiler than can compile Python to machinecode like C?

alex23 wuwei23 at gmail.com
Fri Mar 1 05:31:48 CET 2013


On Mar 1, 1:47 pm, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
> Cython is not a Python compiler. Cython code will not run in a vanilla
> Python implementation. It has different keywords and syntax, e.g.:
>
> cdef inline int func(double num):
>     ...
>
> which gives SyntaxError in a Python compiler.

Cython has had a "pure Python" mode for several years now that allows
you to decorate Python code or augment it with additional files
containing the C specific declarations:

http://docs.cython.org/src/tutorial/pure.html

Both of which will be ignored by the regular Python interpreter,
allowing you to write Python that is also suitable for Cython without
the errors you mention.




More information about the Python-list mailing list