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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Mar 1 20:49:40 EST 2013


On Fri, 01 Mar 2013 08:48:34 +0100, Stefan Behnel wrote:

> Steven D'Aprano, 01.03.2013 04:47:
>> On Thu, 28 Feb 2013 22:03:09 +0100, Stefan Behnel wrote:
>> 
>>> The most widely used static Python compiler is Cython
>> 
>> 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.
> 
> Including Cython, if you're compiling a ".py" file. The above is only
> valid syntax in ".pyx" files. Two languages, one compiler. Or three
> languages, if you want, because Cython supports both Python 2 and Python
> 3 code in separate compilation modes.


Ah, that's very interesting, and thank you for the correction. I have re-
set my thinking about Cython.



-- 
Steven



More information about the Python-list mailing list