Is python very slow compared to C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Felipe Almeida Lessa

    #16
    Re: Is python very slow compared to C

    Em Dom, 2006-02-12 às 04:33 -0800, bonono@gmail.co m escreveu:[color=blue]
    > Felipe Almeida Lessa wrote:[color=green]
    > > Em Dom, 2006-02-12 às 03:20 -0800, bonono@gmail.co m escreveu:[color=darkred]
    > > > 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.[/color]

    You talked about "batteries included", and that isn't related to the
    language. I said .NET in reference to what you said. The part about the
    language is my own opinion, I just didn't want to say anything about C#,
    Boo, J#, Nemerle or any other language that targets the .NET framework.
    In the case of Python, as well as Java, the language has the same name
    as the framework, and this may have lead you to mistake me.

    --
    "Quem excele em empregar a força militar subjulga os exércitos dos
    outros povos sem travar batalha, toma cidades fortificadas dos outros
    povos sem as atacar e destrói os estados dos outros povos sem lutas
    prolongadas. Deve lutar sob o Céu com o propósito primordial da
    'preservação' . Desse modo suas armas não se embotarão, e os ganhos
    poderão ser preservados. Essa é a estratégia para planejar ofensivas."

    -- Sun Tzu, em "A arte da guerra"

    Comment

    • Björn Lindström

      #17
      Re: Is python very slow compared to C

      Felipe Almeida Lessa <felipe.lessa@g mail.com>:
      [color=blue]
      > In the case of Python, as well as Java, the language has the same
      > name as the framework, and this may have lead you to mistake me.[/color]

      Not really, in either case. There's Python for both .NET and for the
      Java VM.

      --
      Björn Lindström <bkhl@stp.lingf il.uu.se>
      Student of computational linguistics, Uppsala University, Sweden

      Comment

      • Steven D'Aprano

        #18
        Re: Is python very slow compared to C

        On Sun, 12 Feb 2006 03:03:20 -0800, bearophileHUGS 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...[/color]

        We do actually agree. You did explain why the speed of the language itself
        is rarely the critical factor. My criticism is that whatever good your
        post would have done was nullified by your opening comment stating that
        Python is very slow -- a comment which I think is not only harmful, but
        wrong, benchmarks like the one you linked to not withstanding.

        I think it is wrong to call Python "very slow" just because it is slower
        than some other language or languages, for the same reason it would be
        wrong to describe the population of the UK as "very low" because 60
        million people is a smaller number than China or India's one billion plus.
        Doing so merely reinforces the premature optimizer's message that any
        language that isn't C (and sometimes Lisp) is "not fast enough".

        The benchmark you pointed to are of limited use for application
        developers. (Their value to language designers is another story.) Given
        that Ocaml is (say) 200 times faster than Python on average, it tells the
        application developer virtually nothing about the performance of his
        application. And that's what user's care about -- they couldn't care less
        about binary trees or partial sums, they care about how long it takes to
        render a JPEG, open an email, save their files, query the database,
        display a window, and so forth. Few application level tasks are limited by
        the speed of the language, not these days.

        You don't believe me? Consider the following:

        When you drag your mouse over text in a graphical text editor, the text
        highlights. How much money would you be prepared to pay to make that
        highlighting occur 200 times faster? $100? $1? One cent? Chances are you
        wouldn't pay a thing, because it is already fast enough, and making it
        faster is of zero value to you -- even if highlighting ten gigabytes of
        text might be uncomfortably slow.

        What about opening an email? How much would you pay to reduce the time it
        takes to open and display an email from a hundredth of a second to
        virtually instantaneously ? I suggest that most people would consider 0.01s
        to already be be "virtually instantaneously ".

        The important question isn't "is Python fast or slow?", it is "is Python
        fast enough?". That's a question that doesn't have a simple answer,
        because it depends. Fast enough to do what?

        But, in general, more often than not, Python is fast enough. The extra
        value of using something like Lua or Ocaml or even C is just not enough to
        make up for the disadvantages of using those languages.

        Of course Python isn't always fast enough. Please don't waste your time
        coming up with practical examples where pure Python is objectively too
        slow for a certain task, because you won't be telling me anything I don't
        already know.

        But the developer doesn't have to write pure Python, he can call a module
        written in C, or change the algorithm, or find another way to accomplish
        the same end result. Or even decide that for this specific task, Python is
        not the language to use. These are all good solutions, but they don't mean
        that Python is "very slow" in general. Even C is not always fast enough,
        but we wouldn't say C is "very slow" just because it can't calculate the
        first million Mersenne Primes in twenty milliseconds.


        --
        Steven.

        Comment

        • Steven D'Aprano

          #19
          Re: Is python very slow compared to C

          On Sun, 12 Feb 2006 05:31:28 -0800, =?iso-8859-1?q?Luis_M._Gon z=E1lez?=
          wrote:
          [color=blue]
          > 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.[/color]

          Read his post again. He didn't ask a specific question at all, and he
          certainly didn't mention execution speed. He asked a vague, meaningless
          question about whether Python was "slow compared to C".

          Slow to learn? No, Python is easier to learn than C.

          Slow to compile? No, Python handles compiling to byte-code transparently,
          you will rarely even notice it.

          Slow to debug? That depends on the nature of the bug, but generally no.
          It is much easier to write correct code the first time in Python than in
          C, and even if the code isn't correct, Python makes it easier (and
          therefore faster) to debug it.

          Slow to execute? No, for many common tasks execution speed is either fast
          enough regardless of the language, or it is limited by things like user
          input, I/O, memory or other factors independent of the language the code
          is written in.

          If the task is limited by the CPU and not I/O etc., pure Python code with
          no C extensions or Psycho optimizations might be slower than C code, but
          that tells us virtually nothing about whether it is too slow. After all,
          my car is slower than a F-11 fighter plane, but my car is plenty fast
          enough for driving to the shop and back, and a car is a far more practical
          solution to the task even though a F-11 would be faster.



          --
          Steven.

          Comment

          • bonono@gmail.com

            #20
            Re: Is python very slow compared to C


            Steven D'Aprano wrote:[color=blue]
            > But, in general, more often than not, Python is fast enough. The extra
            > value of using something like Lua or Ocaml or even C is just not enough to
            > make up for the disadvantages of using those languages.
            >[/color]
            What is the disavantage of Lua comparing with Python ? Or Ocaml
            comparing with Python ?

            Comment

            • Cameron Laird

              #21
              Re: Is python very slow compared to C

              In article <1139751088.720 150.80010@g43g2 000cwa.googlegr oups.com>,
              Luis M. González <luismgz@gmail. com> wrote:

              Comment

              • Steven D'Aprano

                #22
                Re: Is python very slow compared to C

                On Sun, 12 Feb 2006 06:20:10 -0800, bonono wrote:
                [color=blue]
                >
                > Steven D'Aprano wrote:[color=green]
                >> But, in general, more often than not, Python is fast enough. The extra
                >> value of using something like Lua or Ocaml or even C is just not enough to
                >> make up for the disadvantages of using those languages.
                >>[/color]
                > What is the disavantage of Lua comparing with Python ? Or Ocaml
                > comparing with Python ?[/color]

                If your developer gets hit by a bus, you won't easily find a replacement.
                This may not be a factor if you are programming for pleasure, but in the
                commercial world of software development, availability of skilled
                programmers is absolutely critical for the use of a language.

                I realise that neither Lua nor Ocaml are entirely unknowns, both have been
                used commercially, but I believe Python developers are more widely
                available.

                Google "python programming": 19,000,000 hits.
                Google "lua programming": 574,000 hits.
                Google "ocaml programming": 325,000 hits.

                That will give you a rough estimate for the amount of resources out there
                on the web for each language. By comparison, even Forth gives 13 million
                plus hits, and who uses Forth?

                Another rough measure of the availability of resources is the Dummies test:

                Google "python for dummies": 323,000 hits.
                Google "lua for dummies": 46,400 hits.
                Google "ocaml for dummies": 693 hits.

                Only Python For Dummies is an actual dead-tree book. I think it is safe to
                conclude that Lua and Ocaml offer far fewer resources for somebody looking
                to learn the language than does Python.

                Lua appears to be *too* lightweight, without even classes or inheritance,
                and a single data type where Python has dicts, sets, tuples and lists.

                Ocaml seems to use more punctuation than I'm comfortable with (lots of
                double semi-colons and -> symbols), but Python seems to be moving along
                those lines too with list and generator comprehensions, and none of us
                really want to return to Cobol's verbose arithmetic.

                Wikipedia says "However, [Ocaml] also forces the programmer to conform to
                the constraints of the type system, which can require careful thought and
                close attention. ... effective use of OCaml's type system can require some
                sophistication on the part of the programmer." That suggests that writing
                Ocaml code may be more difficult than writing Python code. Wikipedia also
                emphasises how hard it is for the compiler to generate good quality
                machine code from Ocaml, which suggests that perhaps the compilation stage
                could be slow.


                --
                Steven.

                Comment

                • bonono@gmail.com

                  #23
                  Re: Is python very slow compared to C


                  Steven D'Aprano wrote:[color=blue]
                  > Lua appears to be *too* lightweight, without even classes or inheritance,
                  > and a single data type where Python has dicts, sets, tuples and lists.
                  >[/color]
                  I believe Lua does have features to implement class/inheritance.

                  As for the distinction of dict/set/tuple/list or one single table data
                  type(which can be used as either dict or list and implemented as set,
                  not sure about tuple), it is up to debate.

                  Though I have mentioned in another post that the batteries in Python is
                  extremely appealing to solve real world problems as no matter how good
                  a language can be, re-implementing something from scratch is always a
                  pain(and error prone).

                  Comment

                  • diffuser78@gmail.com

                    #24
                    Re: Is python very slow compared to C

                    Thnaks everybody for their comments. I am an average programmer in C
                    and wanted to make a hop to python and was just trying to clear my mind
                    with the confusions. Bit I guess I will go ahead and spend some time
                    with python and do my next project in python.


                    thanks for the feedback

                    Comment

                    • PA

                      #25
                      Re: Is python very slow compared to C


                      On Feb 12, 2006, at 16:11, Steven D'Aprano wrote:
                      [color=blue]
                      > availability of skilled programmers is absolutely critical for the use
                      > of a language.[/color]

                      By that measure, we should all be using Java, no?

                      "TIOBE Programming Community Index"

                      [color=blue]
                      > By comparison, even Forth gives 13 million plus hits, and who uses
                      > Forth?[/color]

                      Anyone writing in English:

                      Answers is the place to go to get the answers you need and to ask the questions you want

                      [color=blue]
                      > Lua appears to be *too* lightweight, without even classes or
                      > inheritance,[/color]

                      Programming in Lua
                      Object-Oriented Programming

                      [color=blue]
                      > and a single data type where Python has dicts, sets, tuples and lists.[/color]

                      "Lua gives you the power; you build the mechanisms."
                      -- Roberto Ierusalimschy, "Programmin g in Lua", December 2003


                      Cheers

                      --
                      PA, Onnay Equitursay


                      Comment

                      • Cameron Laird

                        #26
                        Is Forth for real?

                        In article <pan.2006.02.12 .15.11.04.73931 4@REMOVETHIScyb er.com.au>,
                        Steven D'Aprano <steve@REMOVETH IScyber.com.au> wrote:

                        Comment

                        • Steven D'Aprano

                          #27
                          Re: Is python very slow compared to C

                          On Sun, 12 Feb 2006 17:44:50 +0100, PA wrote:
                          [color=blue]
                          > On Feb 12, 2006, at 16:11, Steven D'Aprano wrote:
                          >[color=green]
                          >> availability of skilled programmers is absolutely critical for the use
                          >> of a language.[/color]
                          >
                          > By that measure, we should all be using Java, no?[/color]

                          I said nothing about whether Lua or Ocaml were good languages to take up
                          if you want to learn a programming language. In fact, it follows from
                          simple economics that individual developers should avoid languages that
                          are too popular. No matter how good you are as a Visual Basic programmer,
                          the price you can command will be pushed downwards by competition with
                          millions of other VB programmers.

                          I was talking about the other side of the equation. If you are hiring
                          developers to work for you, it is absolutely critical that there is no
                          shortage of skillful programmers in the language(s) you use. "No shortage"
                          doesn't mean "only use Java" -- there are disadvantages to Java that
                          outweigh the fact that there is no shortage of developers.

                          [color=blue]
                          > "TIOBE Programming Community Index"
                          > http://www.tiobe.com/tpci.htm
                          >[color=green]
                          >> By comparison, even Forth gives 13 million plus hits, and who uses
                          >> Forth?[/color]
                          >
                          > Anyone writing in English:
                          >
                          > http://www.answers.com/forth&r=67[/color]

                          Which might be relevant if I searched for "forth", but I didn't. I googled
                          on "forth programming". Yes, there will be some false positives, but I
                          never claimed that this was anything more than a rough and imprecise
                          estimate of the availability of resources for the languages.

                          [color=blue][color=green]
                          >> Lua appears to be *too* lightweight, without even classes or
                          >> inheritance,[/color]
                          >
                          > Programming in Lua
                          > Object-Oriented Programming
                          > http://www.lua.org/pil/16.html[/color]

                          Did you actually bother to read the page you linked to? It describes how
                          you can emulate object-like behaviour for Lua tables. The following page
                          is even more explicit: "Lua does not have the concept of class".

                          That means that the object-oriented framework, which you get for free in
                          Python, has to be at least partially handled by the programmer in Lua.
                          Perhaps Lua makes it easy to do, but it is still something that doesn't
                          need to be done in Python because it is already there.

                          [color=blue][color=green]
                          >> and a single data type where Python has dicts, sets, tuples and lists.[/color]
                          >
                          > "Lua gives you the power; you build the mechanisms."
                          > -- Roberto Ierusalimschy, "Programmin g in Lua", December 2003
                          > http://www.lua.org/pil/12.1.2.html[/color]

                          Which is fine, but the more mechanisms you have to build, the longer it
                          will take you to actually get to the important work, which is putting it
                          all together to create your application.



                          --
                          Steven.

                          Comment

                          • Steven D'Aprano

                            #28
                            Re: Is Forth for real?

                            On Sun, 12 Feb 2006 17:08:02 +0000, Cameron Laird wrote:
                            [color=blue]
                            > In article <pan.2006.02.12 .15.11.04.73931 4@REMOVETHIScyb er.com.au>,
                            > Steven D'Aprano <steve@REMOVETH IScyber.com.au> wrote:
                            > .
                            > .
                            > .[color=green]
                            >>on the web for each language. By comparison, even Forth gives 13 million
                            >>plus hits, and who uses Forth?[/color]
                            > .
                            > .
                            > .
                            > The programmers of, among other things, the FedEx bar-code reader,
                            > the Sun boot loader, and parts of the Space Shuttle.[/color]


                            Okay, so that's three... *wink*

                            You missed Apple's boot loader.

                            I love Forth. I'm no good at thinking at that low count-the-bytes level,
                            but if I was, I'd much prefer to use Forth than C or assembly. I've got a
                            bunch of Forth books here, and when I'm bored I read them for
                            entertainment, and dream. I love the fact that Forth is still in use. But
                            I'm under no illusions that there are millions of Forth developers getting
                            paid to write in Forth.



                            --
                            Steven.

                            Comment

                            • PA

                              #29
                              Re: Is python very slow compared to C


                              On Feb 12, 2006, at 18:18, Steven D'Aprano wrote:
                              [color=blue]
                              > Did you actually bother to read the page you linked to?[/color]

                              I did 8^)

                              "Lua — Story of O"


                              Cheers

                              --
                              PA, Onnay Equitursay


                              Comment

                              • Roy Smith

                                #30
                                Re: Is Forth for real?

                                Steven D'Aprano <steve@REMOVETH IScyber.com.au> wrote:
                                [color=blue]
                                > I love Forth. I'm no good at thinking at that low count-the-bytes level,
                                > but if I was, I'd much prefer to use Forth than C or assembly. I've got a
                                > bunch of Forth books here, and when I'm bored I read them for
                                > entertainment, and dream. I love the fact that Forth is still in use. But
                                > I'm under no illusions that there are millions of Forth developers getting
                                > paid to write in Forth.[/color]

                                If you like Forth, take a look at PostScript. Most people think of
                                PostScript as a print file format and don't realize it's a real programming
                                language. Variables, functions, loops, if statements, and all that good
                                stuff. The syntax is very Forth-like.

                                Comment

                                Working...