Python is far from a top performer according to benchmark test...

C

Carl

"Nine Language Performance Round-up: Benchmarking Math & File I/O"
http://www.osnews.com/story.php?news_id=5602

I think this is an unfair comparison! I wouldn't dream of developing a
numerical application in Python without using prebuilt numerical libraries
and data objects such as dictionaries and lists.

I have been experimenting with numerical algorithms in Python with a heavy
use of the Numeric module. My experience is that Python is quite fast in
comparison with (and sometimes as fast as) traditional languages such as C
or C++.

The greatest advantage of Python is the great increase in productivity and
the generation of a much smaller number of bugs due to the very clean and
compact structure Python invites you to produce. Sometimes it amazes me how
fast I can produce a working algorithm in Python. The step from an
algorithmic outline on a paper to a working code is very short. The
interactive nature of the Python console invites numerical experimentation
and data exploration. This wasn't mentioned in the article, what a pity!

Carl
 
I

Irmen de Jong

Carl said:
"Nine Language Performance Round-up: Benchmarking Math & File I/O"
http://www.osnews.com/story.php?news_id=5602

This benchmark is beaten to pulp in the discussion about it on slashdot.
It's a real stupid benchmark (as most benchmarks are) IMNSHO.

I mean, using python's arbitrary precision long object for 'math'
and comparing it to the other languages' long /machine types/... come on.
And thats just one of the flaws.

--Irmen
 
K

Krzysztof Stachlewski

I have been experimenting with numerical algorithms in Python with a heavy
use of the Numeric module. My experience is that Python is quite fast in
comparison with (and sometimes as fast as) traditional languages such as C
or C++.

With "heavy use of Numeric module" you were calling functions
written in C. So how can you say that Python is fast,
when C code is doing all the work.

Stach
 
S

Samuel Walters

|Thus Spake Krzysztof Stachlewski On the now historical date of Fri, 09
Jan 2004 22:13:58 +0100|
With "heavy use of Numeric module" you were calling functions written in
C. So how can you say that Python is fast, when C code is doing all the
work.

Because python works best as a glue layer coordinating outside libraries
and functionality. I think the true strength of python comes from a
one-two punch of "Fast and pretty implementation with easy interface to
lower level tools." When python is not the right tool, we code our
solution with the right tool and then use python to glue all the right
tools together. For numerical processing, C is the right tool, but python
is not. Therefore, noone tried to use the wrong tool, they just used the
right tool and gave it python bindings so that python could act as a
coordinator.

I read the benchmark and I think it doesn't measure python in it's target
area. That's like taking a world-class marathon runner and wondering why
he doesn't compete well in a figure-skating event.

Sam Walters.
 
J

JanC

Krzysztof Stachlewski said:
With "heavy use of Numeric module" you were calling functions
written in C. So how can you say that Python is fast,
when C code is doing all the work.

I think all (or at least most) of the tested compilers, VMs, etc. were
written in C/C++, and thus are using libraries written in C/C++...
 
J

Jeff Epler

numarray is probably the perfect example of getting extremely good
performance from a few simple constructs coded in C. (numarray-0.8 is
less then 50k lines of C code, including comments and blank lines, so
it's also very simple given the amount of "bang" it provides)

All your important logic is in Python, you're in no way stuck worrying
about buffer lengths, when to call free(), and all those other things
that drive me crazy when I try to write in C.

If I had to execute my Python programs without executing any code
written in "C" behind the scenes, well, I'd be stuck. Of course, the
situation is about the same for any language you care to name, and if
not then substitute "machine code".

Jeff
 
I

Iwan van der Kleyn

Carl said:
I think this is an unfair comparison! I wouldn't dream of developing a
numerical application in Python without using prebuilt numerical libraries
and data objects such as dictionaries and lists.

Well, that may be true. And many applications spend most of their time
in fast libraries anyway (GUI/DB/app servers) etc. Nice examples are Boa
Constructor and Eric3 which are fully implemented in Python and run
comfortably fast, thanks to the WxWindows and Qt libraries.

But I really dont' swallow the argument. In the few years that I'm
working with Python, I've encountered on several occasions performance
bottlenecks. And often a solution through partial implementation in C or
improvements in the algorithm is just not feasible. To paraphrase Kent
Beck: in real life you make your program run, then work and then your
manager says you've run out of time. You just cannot make it run as fast
as you would like it as well.

In other words: it would be nice if Python on average would run faster
so the need for optimisation would lessen. Psyco is a nice option to
have, though not as clear cut as I thought it would be:

http://www-106.ibm.com/developerworks/linux/library/l-psyco.html
The greatest advantage of Python is the great increase in productivity and
the generation of a much smaller number of bugs due to the very clean and
compact structure Python invites you to produce.

So dogma dictates. And I've found it to be true on many occasions, if
not all. BUT, the famed Python Productivity Gain is very difficult to
quantify. And for me that's a BIG but. I'm trying to push Python within
my company. Nicely presented "performance benchmarks" go down well with
management, bevause those are quantities which are supposedly
understood. And Python does not come across very possitively in that
respect.

Regards,

Iwan
 
T

Tim Churches

"Nine Language Performance Round-up: Benchmarking Math & File I/O"
http://www.osnews.com/story.php?news_id=5602

I think this is an unfair comparison! I wouldn't dream of developing a
numerical application in Python without using prebuilt numerical libraries
and data objects such as dictionaries and lists.

Benchmarks like those reported are nearly worthless, but nevertheless,
it would be interesting to re-run the them using Numeric Python and/or
Pyrex.

I notice that the author of those benchmarks, Christopher W.
Cowell-Shah, has a PhD in philosophy. Perhaps Python's very own
philosophy PhD, David Mertz, might like to repeat the benchmarking
exercise for one of his columns, but including manipulation of more
realistic data structures such as lists, arrays and dictionaries, as
Carl suggests. I'm sure it would be a popular article, and provide a
counterpoint to the good Dr Mertz's previous articles on Psyco.

--

Tim C

PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere
or at http://members.optushome.com.au/tchur/pubkey.asc
Key fingerprint = 8C22 BF76 33BA B3B5 1D5B EB37 7891 46A9 EAF9 93D0



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA//yC2eJFGqer5k9ARAg01AKD03VKBBxNZBEmvHNljD+TJNDMtzACeJhqN
5bvT3a5t1NQfLnpvPex3KF8=
=Lhb+
-----END PGP SIGNATURE-----
 
C

Carl

Krzysztof said:
With "heavy use of Numeric module" you were calling functions
written in C. So how can you say that Python is fast,
when C code is doing all the work.

Stach

Well, I guess you are right!

What I meant was that when I run my Python algorithm it runs "almost as fast
as" when I run similar code in C or C++. This is of course due to the
highly efficient Numeric module. However, the point is that Python is a
viable language from a numerical perspective.

Carl
 
T

Tim Churches

With "heavy use of Numeric module" you were calling functions
written in C. So how can you say that Python is fast,
when C code is doing all the work.

Well, yes, but the Python VM is also written in C, and every time you
make a call to a dictionary, or list etc, it is C code which is doing
all the work. If you like, you could say that Python is a set of
extremely clever wrappers around a bunch of optimised C code - but that
rather diminishes the achievement of Python. I dare say that the
Microsoft .NET and Visual Basic VMs are also written in C/C++, so you
could say the same things about them - but I don't think that is a
useful perspective.
--

Tim C

PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere
or at http://members.optushome.com.au/tchur/pubkey.asc
Key fingerprint = 8C22 BF76 33BA B3B5 1D5B EB37 7891 46A9 EAF9 93D0



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA//yKZeJFGqer5k9ARApbeAKC0SnajS1CQ/b6w9m+BfBLtLMeptwCg9s+y
szgtzQnlsRc3cYBsNf0T7Wc=
=9rbb
-----END PGP SIGNATURE-----
 
J

JanC

Tim Churches said:
I notice that the author of those benchmarks, Christopher W.
Cowell-Shah, has a PhD in philosophy. Perhaps Python's very own
philosophy PhD, David Mertz, might like to repeat the benchmarking
exercise for one of his columns, but including manipulation of more
realistic data structures such as lists, arrays and dictionaries, as
Carl suggests.

And then don't forget to publish it on /. or nobody sees it... ;-)
 
P

Peter Hansen

Iwan said:
In other words: it would be nice if Python on average would run faster
so the need for optimisation would lessen.

I disagree with the above. My opinion has long been that Python runs
adequately fast and that few people should need to spend much time on
optimization. Maybe that sort of view should be put to the test.

This is my "straw poll" question:

Do you spend a "significant" amount of time actually optimizing your
Python applications? (Significant is here defined as "more than five
percent of your time", which is for example two hours a week in a
40-hour work week.)

Note the distinction between "actually optimizing" and "worrying about
optimization" and such things. If you pause briefly during coding and
rewrite a line to use a more efficient idiom, I don't consider that to be
"optimization" for purposes of this question. Optimization would require
roughly (a) noticing that performance was inadequate or actual profiling
your code, and (b) rewriting specifically to get adequate performance.
Algorithmic improvements that you would make regardless of implementation
language do not qualify, and wasting time optimizing a script that you
run once a year so it takes ten seconds instead of fifteen also does not
qualify because you certainly didn't need to do it...

Yes or no answers suffice, but feel free to follow up with a paragraph
qualifying your answer (or quantifying it!). :)

-Peter
 
P

Paul Rubin

Peter Hansen said:
This is my "straw poll" question:

Do you spend a "significant" amount of time actually optimizing your
Python applications? (Significant is here defined as "more than five
percent of your time", which is for example two hours a week in a
40-hour work week.)

Yes, absolutely.
Algorithmic improvements that you would make regardless of implementation
language do not qualify, and wasting time optimizing a script that you
run once a year so it takes ten seconds instead of fifteen also does not
qualify because you certainly didn't need to do it...

Sometimes I'll take the time to implement a fancy algorithm in Python
where in a faster language I could use brute force and still be fast
enough. I'd count that as an optimization.
 
D

Dave Brueck

Iwan:
So dogma dictates. And I've found it to be true on many occasions, if
not all. BUT, the famed Python Productivity Gain is very difficult to
quantify. And for me that's a BIG but. I'm trying to push Python within
my company. Nicely presented "performance benchmarks" go down well with
management, bevause those are quantities which are supposedly
understood.

Understood, perhaps, but very often irrelevent. That being the case, using
performance benchmarks to argue your case is a weak approach.

If you're talking to management, talk to them about something they care about,
like money. For most programs it's hard to translate performance improvements
into money: e.g. it's hard to assert that by doubling the speed of your
spell-checker implementation that sales will increase. There of course are
exceptions, but even then there's no guarantee that management would still
prefer performance above other factors if given a choice.

It's much more powerful to speak about reduced time to market, for example. Or
the ability to compete against companies with legions of programmers. Or the
decreased time it takes to turn ideas into implemented features (especially
when it's your competitor that came up with the idea). Or a lower cost of
changing directions technologically. Etc.

-Dave
 
D

Dave Brueck

Peter said:
I disagree with the above. My opinion has long been that Python runs
adequately fast and that few people should need to spend much time on
optimization. Maybe that sort of view should be put to the test.

This is my "straw poll" question:

Do you spend a "significant" amount of time actually optimizing your
Python applications? (Significant is here defined as "more than five
percent of your time", which is for example two hours a week in a
40-hour work week.)

Yay, straw poll! ;-)

I program in Python full-time and each spend approximately zero hours
optimizing. In the past two years I can think of two instances in which I went
into heavy optimization mode: one was for a web server that needed to handle
hundreds of requests per second and the other was a log processor that needed
to parse and process several gigabytes of log data per hour.

In the server I added a tiny C extension to make use of the Linux sendfile API,
all the other optimizations were algorithmic. In the log processor all the
optimizations ended up being either algorithmic or doing fewer dumb things
(like recomputing cacheable data).
 
K

Krzysztof Stachlewski

JanC said:
"Krzysztof Stachlewski" <[email protected]> schreef:

I think all (or at least most) of the tested compilers, VMs, etc. were
written in C/C++, and thus are using libraries written in C/C++...

Well, yes.
Whether or not you can say that a piece of code
is *really* implemented in a chosen language and not
in "the language that this language is implemented in" ;-)
is a matter of scale.

I just think that the Numeric package
is not the best example of the speed of Python itself.

Stach
 
M

Mike C. Fletcher

Dave said:
Peter wrote:

....


Yay, straw poll! ;-)
Indeed, yay ;) .

I am often found optimising. The total time spent on it is probably
somewhere around 1-2% of total (after all, I do still *use* Python, it's
not like it's killing me). A lot of my projects are speed-sensitive
(e.g. OpenGLContext trying to give interactive frame-rates in 3D
scenegraph rendering, SimpleParse trying to create really fast parsers,
web-sites trying to process 10s of thousands of records into summary
views interactively), but I don't think I'm *that* far from the norm in
the amount of time spent on optimisation.

I'd be surprised if there's not some difference between the experience
of library programmers and application programmers in this regard.
Library developers tend to need to focus more effort on performance to
allow users of the libraries some inefficiencies in their usage. That
effort tends to be more in the planning stages, though, making sure
you've chosen good algorithms, estimating work-loads and required
throughput. You try to make sure the library is robust and fast by
designing it that way, not by trying to optimise it after the fact. You
plan for worst-case scenarios, and as a result you become "worried"
about performance. An application developer is normally going to use
optimised libraries and just run with it, only needing to deal with
unacceptable performance if it happens to show up in their particular
project.

Anyway, back to it,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
 
M

Mike C. Fletcher

Rene said:
Mike C. Fletcher:



By an unoptimized or by an optimizing coworker? :)
Well, in a perfect world, it would be by a lovely and svelte lady,
missing her husband and seeking to drag me off to connubial bliss (we'll
assume for propriety's sake that the husband would be me), but in my sad
and lonely condition, it's normally I who finds myself late at night,
feverishly optimising ;) :) .

All a man really needs to be happy is work, and a woman to drag him away
from it, or so I'm told,
Mike(y)

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
 
J

Jp Calderone

I disagree with the above. My opinion has long been that Python runs
adequately fast and that few people should need to spend much time on
optimization. Maybe that sort of view should be put to the test.

This is my "straw poll" question:

Do you spend a "significant" amount of time actually optimizing your
Python applications? (Significant is here defined as "more than five
percent of your time", which is for example two hours a week in a
40-hour work week.)

No.

Jp
 

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,778
Messages
2,569,605
Members
45,237
Latest member
AvivMNS

Latest Threads

Top