Python is slow?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kay Schluehr

    #16
    Re: Python is slow?

    On 23 Sep., 21:23, J Peyret <jpey...@gmail. comwrote:
    On Sep 23, 8:31 am, bearophileH...@ lycos.com wrote:
    >
    Guys, this looks like a great data structure/algo for something I am
    working on.
    >
    But... where do I find some definitions of the original BK-tree idea?
    *geometric data structures*. Just google for it.

    Comment

    • Robert Kern

      #17
      Re: Python is slow?

      sturlamolden wrote:
      On Sep 23, 9:17 pm, Robert Kern <robert.k...@gm ail.comwrote:
      >
      >You could also drop it on the scipy.org wiki in the Cookbook category.
      >
      Yes, if I could figure out how to use it...
      What's confusing? You do have to create a profile:



      --
      Robert Kern

      "I have come to believe that the whole world is an enigma, a harmless enigma
      that is made terrible by our own mad attempt to interpret it as though it had
      an underlying truth."
      -- Umberto Eco

      Comment

      • sturlamolden

        #18
        Re: Python is slow?

        On Sep 23, 10:05 pm, Robert Singer <rsinger@____.c omwrote:
        May I ask what are your main objections to it ?
        1. gfortran is not Absoft.

        2. If I program the same in C99 and Fortran 95, and compile with gcc
        and gfortran, the C99 code runs a lot faster (I've only tested with
        wavelet transforms).

        3. gfortran is not Absoft.






        Comment

        • sturlamolden

          #19
          Re: Python is slow?

          On Sep 23, 10:16 pm, Robert Kern <robert.k...@gm ail.comwrote:
          What's confusing? You do have to create a profile:
          How do I add a new page to the wiki? I'm only able to edit the front
          page of the cookbook. But it doesn't help to add link there if I have
          no page to link. (I may be incredibly stupid though.)

          Comment

          • Robert Kern

            #20
            Re: Python is slow?

            sturlamolden wrote:
            On Sep 23, 10:16 pm, Robert Kern <robert.k...@gm ail.comwrote:
            >
            >What's confusing? You do have to create a profile:
            >
            How do I add a new page to the wiki? I'm only able to edit the front
            page of the cookbook. But it doesn't help to add link there if I have
            no page to link. (I may be incredibly stupid though.)
            You just navigate to the URL you want:



            This will show you a page saying:

            """
            This page does not exist yet. You can create a new empty page, or use one of the
            page templates. Before creating the page, please check if a similar page already
            exists.

            Create new empty page
            """

            The latter is a link that you can click.

            Looking at the other Cookbook page sources, I notice that you should add the
            following to the bottom of your page to categorize it appropriately.

            """
            ----
            . CategoryCookboo k
            """

            Then put the link on the main Cookbook page (or do that first, then navigate
            through the link to create the page).

            --
            Robert Kern

            "I have come to believe that the whole world is an enigma, a harmless enigma
            that is made terrible by our own mad attempt to interpret it as though it had
            an underlying truth."
            -- Umberto Eco

            Comment

            • Robert Singer

              #21
              Re: Python is slow?

              On Tue, 23 Sep 2008 13:34:10 -0700 (PDT), sturlamolden
              <sturlamolden@y ahoo.nowrote:
              >1. gfortran is not Absoft.
              I find this comment absurd. What did you mean by it ?
              Yes, gfortran is not Absoft, just as red is not blue (?!).

              I also don't understand whether you're looking for a free or a
              commercial compiler. I got the impression from your previous post that
              money was an object.
              >2. If I program the same in C99 and Fortran 95, and compile with gcc
              >and gfortran, the C99 code runs a lot faster (I've only tested with
              >wavelet transforms).
              Hmm. Unfortunatelly, i have none whatsoever experience in that field.
              Completely different area of study here, so without seeing at least
              some code, I cannot comment anything on that part.

              And 'a lot faster' is a very relative term.
              >
              >3. gfortran is not Absoft.
              >
              True.

              Best regards
              Bob

              Comment

              • sturlamolden

                #22
                Re: Python is slow?

                On Sep 23, 8:52 pm, bearophileH...@ lycos.com wrote:
                Is this a good or bad thing? ;-)
                It seems we have been implementing different algorithms. kd-trees are
                not BK-trees.


                Comment

                • Robert Kern

                  #23
                  Re: Python is slow?

                  Robert Kern wrote:
                  J Peyret wrote:
                  >On Sep 23, 8:31 am, bearophileH...@ lycos.com wrote:
                  >>
                  >Guys, this looks like a great data structure/algo for something I am
                  >working on.
                  >>
                  >But... where do I find some definitions of the original BK-tree idea?
                  >
                  Uh, actually we're talking about kd-trees, not BK-trees. kd-trees are
                  for searching through point sets in a k-dimensional space.
                  My apologies. I did not actually follow bearophile's link, and thought he was
                  talking about kd-trees like Sturla was.

                  --
                  Robert Kern

                  "I have come to believe that the whole world is an enigma, a harmless enigma
                  that is made terrible by our own mad attempt to interpret it as though it had
                  an underlying truth."
                  -- Umberto Eco

                  Comment

                  • bearophileHUGS@lycos.com

                    #24
                    Re: Python is slow?

                    sturlamolden:
                    It seems we have been implementing different algorithms. kd-trees are
                    not BK-trees.
                    http://www.scipy.org/Cookbook/KDTree
                    Sorry for my silly mistake :-)

                    Note: in your code I don't know if the collections.deq ue data
                    structure may help (it's faster than list for appending), but I
                    presume that's not a bottleneck.

                    Bye,
                    bearophile

                    Comment

                    • Eric Brunel

                      #25
                      Re: Python is slow?

                      On Tue, 23 Sep 2008 15:23:12 +0200, sturlamolden <sturlamolden@y ahoo.no>
                      wrote:
                      [...]

                      Would it be possible to post this text to some "persistent " web page with
                      (links to) the code you wrote in both languages? This would be a very
                      interesting resource for people experiencing some resistence when they
                      suggest Python as a possible language because of the 'Python is slow'
                      myth...
                      --
                      python -c "print ''.join([chr(154 - ord(c)) for c in
                      'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"

                      Comment

                      • sturlamolden

                        #26
                        Re: Python is slow?


                        For those who are interested:

                        I've updated the cookbook tutorial on the kd-tree:



                        It now also includes parallel search for multicore CPUs
                        (multiprocessin g standard module). Even if you are not genuinely
                        interested in kd-trees, it shows how to do parallel processing in
                        Python despite of the GIL.




                        Comment

                        • sturlamolden

                          #27
                          Re: Python is slow?


                          I have updated the cookbook entry for yesterday to also include
                          parallel processing for large data sets. Even if you're not interested
                          in kd-trees, it is a good example of what the new multiprocessing
                          standard module can do. There are still people being scared by the
                          GIL, thinking it prevents Python from utilizing multicore processors.


                          Comment

                          • David Cournapeau

                            #28
                            Re: Python is slow?

                            On Wed, Sep 24, 2008 at 3:07 AM, sturlamolden <sturlamolden@y ahoo.nowrote:
                            On Sep 23, 3:44 pm, Robert Singer <rsinger@____.c omwrote:
                            >
                            >Well, python is not a number crunching language. However much we would
                            >like it to be (we would ? :-).
                            >
                            >No scripting language is.
                            >
                            Not even Matlab, R, IDL, Octave, SciLab, S-PLUS or Mathematica?
                            I am fairly experienced in matlab (have been using it extensively for
                            5 years in academical context), and now with numpy, and generally,
                            they are comparable speed-wise. Matlab has some niceties which makes
                            it faster in some simple cases (JIT for loops, function calls faster,
                            sometimes COW semantics means it faster), but numpy (at its core at
                            least) is much more powerful IMHO. Also, matlab is horrible when you
                            want to interface some C to it (the C api is basically broken; in
                            particular, there is no way to gurantee you won't leak memory when you
                            Ctrl+C custom C extensions because the C api does not have facility to
                            deal with signals). I totally gave up matlab for numpy 2 years ago,
                            and never regretted it.

                            I think speed is not the issue when comparing matlab, R and co.
                            Availability of functionalities matter much more. R is quite hard to
                            beat if you need to do advanced statistics, specially since it is the
                            tool of choice for most academic statisticians. I hope numpy/scipy
                            will be there sometime, but it is honestly still quite far in that
                            domain.

                            cheers,

                            David

                            Comment

                            • Aahz

                              #29
                              Re: Python is slow?

                              In article <Y7CdnYRzU-8naEXVnZ2dnUVZ_ sDinZ2d@posted. visi>,
                              Grant Edwards <grante@visi.co mwrote:
                              >
                              >AFAICT, _everybody_ is bad at programming C++.
                              >
                              >One begins to suspect it's not the fault of the programmers.

                              --
                              Aahz (aahz@pythoncra ft.com) <* http://www.pythoncraft.com/

                              "Argue for your limitations, and sure enough they're yours." --Richard Bach

                              Comment

                              • Fly Away

                                #30
                                Re: Python is slow?

                                Matlab's strongest side is data visualization though. Although we have
                                matplotlib, mayavi and possibility of interfacing with gnuplot, it's
                                not anywhere near the capabilities of Matlab.
                                What particular Matlab visualization features are you referring to? I
                                can't think of anything that would justify using the "not anywhere
                                near" term.

                                Cheers,
                                Victor.

                                Comment

                                Working...