469,352 Members | 2,119 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Python vs. Perl vs. PHP?

Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?
Jul 18 '05 #1
17 15320
fa****@jaredweb.com (Fazer) writes:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


yes for two reasons, one relative, one more objective :

- you'll write cleaner and shorter programs with python, so more easy to
optimize
- when you'll really need speed, you'll write standalone web-server with
python, and so a lot more eficient and fast in high trafic.

I've rewrite my "high" trafic web site from php to python and gain 10x of
speed.

--
William Dode - http://flibuste.net
Jul 18 '05 #2
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.

Besides that, PHP is a really ugly language - not only to the eye (which is
admittedly a matter of taste), but a friend of mine currently implements a
PHP->C-Compiler had delved deep into the language implementation - and it
_is_ ugly.

I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
6000 line include vanished from time to time - repeating the request
sometimes solved the problem. That was really nasty.

Regards,

Diez
Jul 18 '05 #3
"Diez B. Roggisch" <de************@web.de> writes:
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml


has somebody tried to run this bench with python2.3 ?

--
William Dode - http://flibuste.net
Jul 18 '05 #4
"Diez B. Roggisch" <de************@web.de> wrote in message news:<bg*************@news.t-online.com>...
Fazer wrote:
Hello,

I am an avid user of PHP and I am just fooling around with Python for
now. I originally wanted to know which one is faster. As in, works
faster. So far, I think PHP is the fastest for dynamic web-content.
Am I wrong?


Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.

Besides that, PHP is a really ugly language - not only to the eye (which is
admittedly a matter of taste), but a friend of mine currently implements a
PHP->C-Compiler had delved deep into the language implementation - and it
_is_ ugly.

I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
6000 line include vanished from time to time - repeating the request
sometimes solved the problem. That was really nasty.

Regards,

Diez


Wow, thanks for link! I will use it as hard proof to lure some of my
friends in using Python! ;-)

This is a little off-topic, but I wish to know how would you turn a
string (or data from a text-file) into an array? For example, maybe
turn each \n into an array.

So a string like:

"This is line 1
This is line 2
This is line 3"

And so when you read that into a list called text text[0] would the
"This is line 1".

Thank you once again.
Jul 18 '05 #5
Nevermind. I RTFM :-) .
Jul 18 '05 #6
In article <7b**************************@posting.google.com >,
Fazer <fa****@jaredweb.com> wrote:

This is a little off-topic, but I wish to know how would you turn a
string (or data from a text-file) into an array? For example, maybe
turn each \n into an array.

So a string like:

"This is line 1
This is line 2
This is line 3"

And so when you read that into a list called text text[0] would the
"This is line 1".


s.split('\n')
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
Jul 18 '05 #7
Diez B. Roggisch wrote:
http://www.bagley.org/~doug/shootout/craps.shtml

Python is place 13, with a speed index of 578. PHP is second last (before
bash) and has a speed index of 197.


Those benchmarks are doubly useless for the question at hand. Firstly,
they only test command line applications. Secondly, PHP is compiled
without optimizations because the rules state that only the default
configuration can be used. See question 8 of the FAQ:

http://www.bagley.org/~doug/shootout/faq.shtml
Graham

Jul 18 '05 #8
Fazer wrote:
[...] I am basically looking for a FAST
alternative to PHP meaning the responce time is fast. Do you think
that Python with using the CGI module is a good solution?


No, CGI is not a good solution in this case, no matter what the language
(except those perverts who use something like C with dietlibc for this).

The base technology to make web requests fast in Python is something
like mod_python or a Python application server. On top of this I'd
recommend you use a Python web framework, of which there are numerous
ones. The hard part is to evaluate them and choose one.

FWIW I'm currently using Quixote running with mod_scgi against Apache,
mostly because I was fed up with the (lack of) Webware documentation,
which I tried first.

-- Gerhard

Jul 18 '05 #9
Gerhard Häring <gh@ghaering.de> wrote in message news:<ma*********************************@python.o rg>...
Fazer wrote:
[...] I am basically looking for a FAST
alternative to PHP meaning the responce time is fast. Do you think
that Python with using the CGI module is a good solution?


No, CGI is not a good solution in this case, no matter what the language
(except those perverts who use something like C with dietlibc for this).

The base technology to make web requests fast in Python is something
like mod_python or a Python application server. On top of this I'd
recommend you use a Python web framework, of which there are numerous
ones. The hard part is to evaluate them and choose one.

FWIW I'm currently using Quixote running with mod_scgi against Apache,
mostly because I was fed up with the (lack of) Webware documentation,
which I tried first.

-- Gerhard

Thanks for the reply! I think I am going to give mod_python a try.
Would I have to be root to install mod_python? Because that's one of
my biggest concerns. I don't have root and I don't want to work on my
windows machine since I am kind of more comfortable working on a Linux
platform.

Basically, most of my Python scripts would just be accessing the MySQL
database and just printing out various data.
Jul 18 '05 #10
Fazer wrote:
Thanks for the reply! I think I am going to give mod_python a try.
Would I have to be root to install mod_python?
Either that or you need to have the privileges to compile Apache +
mod_python and run it on a nonprivileged port (> 1024).
Because that's one of
my biggest concerns. I don't have root and I don't want to work on my
windows machine since I am kind of more comfortable working on a Linux
platform. [...]


mod_python works on Windows as well. The harder part is finding a web
hoster that will host mod_python apps (pythonhosting.com comes to mind).
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.

-- Gerhard

Jul 18 '05 #11
Hi,
Compared to Apache 2.0 with PHP/Zend & Accelerator? I honestl don't think
so. When PHP is compiled to native code it is as fast as Java or C.


There is no such thing like a native compiler for PHP. If you're speaking of
the ZEND compiler - AFAIK that one just does some parse tree caching. As I
mentioned before, a friend of mine works on a php->C (and then native, of
course) compiler.

One thing he has to do is to recreate all the library bindings. These are
really slow implemented in PHP - has something to do with the
parameter-passing. And thats something the ZEND compiler doesn't speed up.

Another thing is PHP session mechanism - the simply persist every session to
the filesystem. Sure, there are FS-Caches, but neverless thats not as fast
as imaginable...

And what do you mean by "As fast as Java or C"? There is a huge difference
in speed between these two.

Not that I think that speed matters much here - usually, the bandwidth,
process creation time and database queries are the bottlenecks.

Regards,

Diez
Jul 18 '05 #12
>> Definitely. See here:

http://www.bagley.org/~doug/shootout/craps.shtml


has somebody tried to run this bench with python2.3 ?


I just picked a few (heapsort.python, methcall.python, objinst.python) tests
and run them on my local machine using 2.2 and 2.3.

The results are that 2.3 seems to need 60-70% of cpu time. Looks good!

time heapsort.python2.3 80000
real 0m4.779s
user 0m3.540s
sys 0m0.000s

time heapsort.python2.2 80000
real 0m5.655s
user 0m5.510s
sys 0m0.030s

Mind you: I didn't do a full benchmarking and didn't even try so!

Diez
Jul 18 '05 #13
> I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?
Jul 18 '05 #14
fa****@jaredweb.com (Fazer) writes:
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?


15EUR/month on http://lost-oasis.fr i write about them because they make a lot
of contributions to open-source...

--
William Dode - http://flibuste.net
Jul 18 '05 #15
Wilk wrote:
fa****@jaredweb.com (Fazer) writes:

I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?

15EUR/month on http://lost-oasis.fr i write about them because they make a lot
of contributions to open-source...


[e:\]ping lost-oasis.fr

Pinging lost-oasis.fr [80.67.180.4] with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 80.67.180.4:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Ahem ....

--Irmen

Jul 18 '05 #16
Fazer wrote:
I personally find it much easier to learn about system administration
and get my own dedicated server for EUR 39/month.


39? Where do you get such a good deal?


http://hetzner.de/ - "Entry Server" EUR 39
http://www.server4free.de/ - EUR 30
http://www.server4free.de/ - VServer (basically User Mode Linux) - EUR 10

http://www.1und1.com/ - EUR 49

These are the cheapest offers of the relevant German providers. They all
come with a considerable setup fee as well, so don't just look at the
monthly fee.

-- Gerhard

Jul 18 '05 #17
Gerhard Häring <gh@ghaering.de> writes:
I personally find it much easier to learn about system
administration and get my own dedicated server for EUR 39/month.

39? Where do you get such a good deal?


http://hetzner.de/ - "Entry Server" EUR 39
http://www.server4free.de/ - EUR 30
http://www.server4free.de/ - VServer (basically User Mode Linux) - EUR 10

http://www.1und1.com/ - EUR 49

These are the cheapest offers of the relevant German providers. They
all come with a considerable setup fee as well, so don't just look at
the monthly fee.


www.usermodelinux.org has links to a bunch of other such providers.
EUR 10 is the lowest monthly price I've seen, but I think there are
some in the 20 USD/month range with low or no setup fees.
Jul 18 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Roy Smith | last post: by
42 posts views Thread by Fred Ma | last post: by
46 posts views Thread by Reinhold Birkenfeld | last post: by
31 posts views Thread by surfunbear | last post: by
68 posts views Thread by Lad | last post: by
9 posts views Thread by Dieter Vanderelst | last post: by
13 posts views Thread by squash | last post: by
12 posts views Thread by rurpy | last post: by
21 posts views Thread by Roy Smith | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.