Yes this language is very slow, but frequently this isn't a problem,
because you are using fast functions/libraries written in C, or you are
doing I/O bound operations. And Psyco, numeric/numarray, ShedSkin can
help in some other cases (Pyrex and other solutions allow you to mix in
lower level languages). If you are looking for pure algorithmic speed
you probably have to go look for other languages, like C, C++, Ocaml,
typed Lisp code, etc.
diffuser78@gmai l.com wrote:[color=blue]
> I have just started to learn python. Some said that its slow. Can
> somebody pin point the issue.
>
> Thans
>[/color]
"Some" doesn't know what he/she/they are talking about.
Generalizations like that upset me because it shows someone
that has some predisposition to some other language and they
don't want to be confused by "facts". Many "compiled
language" programmers fall into this category. Many times
you can write, debug, execute, and document a Python program
before "compiled language" guys can even get started. Many
believe that Python is also more maintainable over time.
When you come back to it in 6 months you will ACTUALLY BE ABLE
TO READ THE CODE. Productivity cannot be measured by
benchmarks alone.
Give Python a try and I'll bet you find that it is fast enough
(that's all that is important right) for all but device
drivers and highly scientific applications (and even then
there are solutions). The parts of Python that need to be
fast have been rewritten as binary libraries. That way you
get the best of both worlds: high level language that has
fast libraries when required.
Try to understand the advantages of this approach, and understand its
costs.
Essentially, everything you do in Python (or related languages)
involves resolving a name. Sometimes the number of dictionary look-ups
(name dereferences) required to do anything is very expensive in
runtime performance.
If your code is not compute-bound (as most codes are not; these days
communication-bound or limited by database performance are more common)
the increase in your own performance will be much more important. If
your code does do so much computing (as mine do) that performance
matters, you may still find Python useful, but it is less of a
slam-dunk.
On Sat, 11 Feb 2006 12:49:32 -0800, diffuser78 wrote:
[color=blue]
> I have just started to learn python. Some said that its slow.[/color]
No, you can learn the basics of Python is only a few hours, and become
very proficient at it in days or weeks. It is much faster to learn Python
than to learn C.
[color=blue]
> Can somebody pin point the issue.[/color]
What is slow? Slow compared to what? Would you prefer to spend three days
writing a program that will run in twenty milliseconds, or three hours
writing the same program which runs in eighty milliseconds? Is the
computer's execution time more important than your development time? If
the computer's time is more valuable than your time, then you should be
writing in assembly language.
Python helps you write shorter code with fewer bugs, much quicker, than C.
If you discover a specific problem that runs too slow in Python, it is
possible to write a C extension to solve that specific problem, while
still having all the other advantages of Python.
On Sat, 11 Feb 2006 13:52:03 -0800, bearophileHUGS wrote:
[color=blue]
> Yes this language is very slow,[/color]
Very slow to do what, compared to what? The decay time of the tau meson?
Slowness is not an absolute quantity. Slowness is relative, and comments
like "Python is very slow" just reinforces the meme that execution speed
is the only important factor -- even if you follow up with a good (and
correct) description of why raw CPU speed is rarely an issue, it is too
late, you've reinforced the meme "only C is good".
I would challenge the assertion that *any* serious modern language is
"very slow" on modern hardware in any meaningful sense. There are plenty
of *specific tasks* which are too slow when written in one language or
another, but that's not the same thing.
Steven D'Aprano>Very slow to do what, compared to what? The decay time
of the tau meson?<
Probably every answer I can give you is wrong for you, so answering is
almost useless... In this thread we have already given the most
pertinent answers to the original question from Diffuse.
I can show you this page, but I think this is useless too for you:
bearophileHUGS@ lycos.com wrote:[color=blue]
> Steven D'Aprano>Very slow to do what, compared to what? The decay time
> of the tau meson?<
>
> Probably every answer I can give you is wrong for you, so answering is
> almost useless... In this thread we have already given the most
> pertinent answers to the original question from Diffuse.
> I can show you this page, but I think this is useless too for you:
> http://shootout.alioth.debian.org/gp...on&lang2=ocaml
>[/color]
Em Dom, 2006-02-12 Ã s 03:03 -0800, bearophileHUGS@ lycos.com escreveu:[color=blue]
> Probably every answer I can give you is wrong for you, so answering is
> almost useless... In this thread we have already given the most
> pertinent answers to the original question from Diffuse.
> I can show you this page, but I think this is useless too for you:
> http://shootout.alioth.debian.org/gp...on&lang2=ocaml[/color]
What they were saying is that at most of the times your program is going
to sit and wait for things like network, hard drive, user input, etc.,
and these cannot be changed by any language. Those benchmarks test only
raw CPU performance.
Yes, sometimes you *need* raw CPU power, but nobody said that in this
case Python is good for you. Python is good at making your life as a
programmer easier, and every Python programmer knows that.
I wanted to see PyRex or C modules versions of that benchmarks, it would
be really nice. This is the approach used to create fast CPU-bound
algorithms in Python, and as such should be tested as thoroughly as
those Python-only counterparts.
And if it matters for you: Google says Python is fast for them, what
else do you want?
diffuser78@gmai l.com napisa³(a):
[color=blue]
> I have just started to learn python. Some said that its slow. Can
> somebody pin point the issue.[/color]
Em Dom, 2006-02-12 Ã s 03:20 -0800, bonono@gmail.co m escreveu:[color=blue]
> However, to me, the strength of python is the batteries that is
> included(and there are more and more coming).[/color]
So .NET is as good as Python? Hmmm... I think the language itself is the
best part of Python, its library is just a complement (a very good and
relevant one, though).
Felipe Almeida Lessa wrote:[color=blue]
> Em Dom, 2006-02-12 às 03:20 -0800, bonono@gmail.co m escreveu:[color=green]
> > However, to me, the strength of python is the batteries that is
> > included(and there are more and more coming).[/color]
>
> So .NET is as good as Python? Hmmm... I think the language itself is the
> best part of Python, its library is just a complement (a very good and
> relevant one, though).[/color]
..NET is not a language, IMO.
Steven D'Aprano wrote:[color=blue]
> What is slow? Slow compared to what? Would you prefer to spend three days
> writing a program that will run in twenty milliseconds, or three hours
> writing the same program which runs in eighty milliseconds? Is the
> computer's execution time more important than your development time? If
> the computer's time is more valuable than your time, then you should be
> writing in assembly language.
>
> Python helps you write shorter code with fewer bugs, much quicker, than C.
> If you discover a specific problem that runs too slow in Python, it is
> possible to write a C extension to solve that specific problem, while
> still having all the other advantages of Python.[/color]
You are right, we all know that, but I think the person who asked this
question doesn't want to hear a sales pitch. He asked a very specific
question regarding execution speed.
Comment