speed with python

mjc4y@henson.cs.virginia.edu
Wed, 5 Jan 94 15:09:30 EST

Hi folks,

this, from the:

"Benchmarks are known to be black
magic, but we do them anyway" department....

I've just finished two rudimentary speed tests with Python, comparing
Python 0.9.9 and Python 0.9.6. It seems the more recent version of
Python is running at about 70-80% of the speed of the older version.

Questions:
- has anyone else noticed this?
- are these figures about the same for version 1.0?
- is there anything I can do (say, in configuring Python)
to recover some or all of the performance of 0.9.6?

thanks,
Matt

---------------

Here are the programs I ran and the results I got from the two Python
versions:

Hardware: sparc 10, SunOS Release 4.1.3
the numbers given fluctuate, of course, but it gives
you a rough idea...

## TEST 1: run a do-nothing loop 10,000 times

------ snip -------

import time
sum = 0
numtrials = 10
for i in range(numtrials):
start = time.millitimer()
for i in range(10000):
pass
stop = time.millitimer()
this_run = stop-start
sum = sum + this_run
print sum / numtrials

------ snip -------

RESULTS:
--------
python 0.9.9 ~= 250
python 0.9.6 ~= 190

(31% increase in time)

## TEST 2: access a large list and sums the elements
------ snip -------

import time
sum = 0
x = 0
numtrials = 100
mylist= range(1000)
for i in range(numtrials):
start = time.millitimer()
for i in mylist:
x = x + mylist[i]
stop = time.millitimer()
this_run = stop-start
sum = sum + this_run
print sum / numtrials

------ snip -------

RESULTS:
--------
python 0.9.9 ~= 68
python 0.9.6 ~= 57
(20% increase in time)

----------------------------------------------------------------------------
"I once bought batteries, but they weren't included,
so I had to buy them again"
----------------------------------------------------------------------------
Matthew Conway University of Virginia
Dept. of Computer Science Charlottesville, VA 22901
conway@Virginia.EDU
----------------------------------------------------------------------------