Is a "real" C-Python possible?

Christian Heimes lists at cheimes.de
Sun Dec 9 17:34:09 EST 2007


Jack wrote:
> I guess this is subjective :) - that's what I felt in my experience
> with web applications developed in Python and PHP. I wasn't able to
> find a direct comparison online.

Please compare the number of serious bugs and vulnerabilities in PHP and
Python.

> I understand. Python modules implemented in Python - this is how
> Python gets its really rich library.

Correct
Python code is much easier to write and multiple times easier to get
right than C code. Everybody with a few months of Python experience can
contribute to the core but it requires multiple years of C and Python
experience to contribute to the C implementation.

> I think most Java-Python benchmarks you can find online will indicate
> that Java is a 3-10 times faster. A few here:
> http://mail.python.org/pipermail/python-list/2002-January/125789.html
> http://blog.snaplogic.org/?p=55

There are lies, damn lies and benchmarks. :)

Pure Python code is not going to beat Java code until the Python core
gets a  JIT compiler. If you want fair results you have to either
disable the JIT in Java or use Psyco for Python. Otherwise you are
comparing the quality of one language implementation to the quality of a
JIT compiler.

> Here's an article that shows the new version of Ruby is
> faster than Python in some aspects (they are catching up :)
> http://antoniocangiano.com/2007/11/28/holy-shmoly-ruby-19-smokes-python-away/ 

The Ruby developers are allowed to be proud. They were able to optimize
some aspects of the implementation to get one algorithm about 14 times
faster. That's good work. But why was it so slow in the first place?

Nevertheless it is just one algorithm that beats Python in an area that
is well known to be slow. Python's numbers are several factors slower
than C code because the overhead of the dynamic language throws lots of
data out of the cache line. If you need fast and highly optimized int
and floating point operations you can rewrite the algorithm in C and
create a Python interface for it.



More information about the Python-list mailing list