Is a "real" C-Python possible?
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Mon Dec 10 06:03:03 EST 2007
Jack a écrit :
> I understand that the standard Python distribution is considered
> the C-Python. Howerver, the current C-Python is really a combination
> of C and Python implementation. There are about 2000 Python files
> included in the Windows version of Python distribution. I'm not sure
> how much of the C-Python is implemented in C but I think the more
> modules implemented in C, the better performance and lower memory
> footprint it will get.
>
> I wonder if it's possible to have a Python that's completely (or at
> least for the most part) implemented in C, just like PHP - I think
> this is where PHP gets its performance advantage.
Which "performance advantage" ???
> Or maybe I'm wrong
> because the core modules that matter are already in C and those Python
> files are really a think wrapper. Anyhow, if would be ideal if Python
> has performance similar to Java, with both being interpreted languages.
<mode="pedantic">
Neither Python nor Java are "interpreted languages", because there's no
such thing as an "interpreted language" - being 'interpreted' (whatever
the definition of 'interpreted') is a quality of an implementation, not
of a language. wrt/ to CPython and Sun's Java implementation, they are
both byte-code compiled - which, according to usual definitions, is not
quite the same thing !-)
</mode>
Now most of the performance difference is due to Java being much less
dynamic than Python, which allow both the compiler and the VM to do much
more optimizations - specially JIT compilation. It's quite harder to
implement such optimizations for a language as dynamic as Python (IIRC,
some language/compiler gurus here mentionned that even compiling Python
to native binary code would not buy that much gain).
Actually, it seems that taking the opposite approach - that is, trying
to implement as much as possible of Python in Python - would be more
promising wrt/ possible JIT compilation, cf the Pypy project.
More information about the Python-list
mailing list