PHP vs. Python

Craig Ringer craig at postnewspapers.com.au
Thu Dec 23 08:02:43 CET 2004


On Thu, 2004-12-23 at 06:03, stephen.mayer at gmail.com wrote:
> Anyone know which is faster?  I'm a PHP programmer but considering
> getting into Python ... did searches on Google but didn't turn much up
> on this.

Others have answered interpretations of your question other than
execution speed. I can't give you numbers on that - you'd probably have
to do some benchmarks yourself - but can offer a few suggestions.

First, Python can be _seriously_ fast for web use. You need to make sure
you're not starting and terminating interpreters all the time, so you'll
need to use a Python embedded web server proxied by Apache (like Zope
does), SCGI (as works well with Quixote), Twisted, or some other way of
running your code persistently. Persistent CGI usually means worrying
about memory leaks, but unless you're using flakey C extension modules
that shouldn't be a problem with Python.

If you have your Python code running as some sort of persistent server,
then you can use tools like Psyco to get a further (often very
impressive) speed boost. The biggest speed-up with Pysco that I've
clocked is 20x, but 3x - 5x is fairly common.

Whether it'll be faster or slower than PHP, I just can't guess. I think
it'd certainly be well worth a try, especially if you're writing any
more complex applications.

That said, for 90% of users development time matters more than execution
speed, and that's another matter entirely.

--
Craig Ringer




More information about the Python-list mailing list