Python vs. Perl vs. PHP?

F

Fazer

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?
 
W

Wilk

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.
 
D

Diez B. Roggisch

Fazer said:
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
 
F

Fazer

Diez B. Roggisch said:
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.
 
A

Aahz

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')
 
G

Graham Breed

Diez said:
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
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Fazer said:
[...] 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
 
F

Fazer

Gerhard Häring said:
Fazer said:
[...] 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.
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Fazer said:
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
 
D

Diez B. Roggisch

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
 
D

Diez B. Roggisch

Definitely. See here:
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
 
F

Fazer

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?
 
I

Irmen de Jong

Wilk said:
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
 
P

Paul Rubin

Gerhard Häring said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top