Python 2 times slower than Perl

Erno Kuusela erno-news at erno.iki.fi
Tue Jul 17 16:50:55 EDT 2001


In article <8f41cfd.0107171238.6ff33b9b at posting.google.com>,
xucs007 at yahoo.com (Xu, C.S.) writes:

| #!/usr/bin/env python
| i = 2.5;
| while i < 1e7:
|         j = 2.5 * 2.5
|         i += 1
| print i, j

| The `time` results on my PII 450M is:
| 	python script:	37.93u 0.03s 0:38.03 99.8%
| 	perl script:	15.36u 0.03s 0:15.42 99.8%
| 	java compiled:	1.07u 0.10s 0:01.20 97.5%
| 	C compiled:	0.24u 0.01s 0:00.25 100.0%

if you put the code in a function, it will be a fair bit faster
since global variable access is slower than local variable access.

| Can anybody explain why Python is always about 1 time
| slower than Perl?

it is not - sometimes it is slower and sometimes faster.

  -- erno



More information about the Python-list mailing list