Announcement

Collapse
No announcement yet.

HOPE: The Ease Of Python With The Speed Of C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by pininety View Post
    Python is also by now often used in labs or sometimes even analysis.

    I fell for example in love with python then I was tasked to write a program which would read data from a oscilloscope using gpib and print the mean values after 2h to a printer.

    My college was writing for over 3 weeks in C and his program still was not working. I used python, installed one external libary and wrote a program of 10 lines of code and had it working. Just awesome. Sure, my program was slower then his would have been but most of the time was spend waiting on IO anyways so it did not matter.

    Still, in some situations I like so see some speed improvements and be it only so I can use python even in high performance situations and not have to spend writing C for 3 weeks.
    Try using Julia or Golang. Python isn't really needed anymore now that better programming languages are available.

    Comment


    • #22
      Originally posted by benmoran View Post
      For those actually looking to compile python, check out Nuitka:
      With the Python compiler Nuitka you create protected binaries out of your Python source code.

      It converts to C++/C style code, does optimizations, and produces binaries (standalone like CX_Freeze, or not). I'm not the author, just a user.
      Interesting, how does it fair against Cython?

      Comment


      • #23
        Originally posted by mmstick View Post
        Try using Julia or Golang. Python isn't really needed anymore now that better programming languages are available.
        I have my eyes on julia but it is just missing the "batteries" of python.
        So with python, I just get a library to deal with, lets say visa, and with julia, there is just nothing yet.
        And the speed just doesn't matter as python is already fast enough.

        Also, convincing my supervisor that I am allowed to use python was hard already, getting him to allow julia which nobody in our group knows (python was known by everybody at the time because all of us use it privately anyways.)

        Comment


        • #24
          Originally posted by pininety View Post
          And the speed just doesn't matter as python is already fast enough.
          Say that to my Monte Carlo simulation. I never even saw it ending with Python, and took just one minute to run with Julia.

          Comment


          • #25
            Originally posted by brk0_0 View Post
            Say that to my Monte Carlo simulation. I never even saw it ending with Python, and took just one minute to run with Julia.
            Do not get me wrong. Hawing better performance with python would be great. As I said before, analysis and simulation would really benefit greatly.
            But I was speaking about my lab work where I most of the time am limited by IO or jsut do not care if it takes 100ms or 1ms as my trigger only occurs once in half an hour.
            I just need a lot of libraries (say for visa, communicating with stuff, having good zip tar etc support and so on) which julia is missing.

            But hey, I am already learning julia just for the fun of it and to have it ready or just use it in the one case there I need the performance.

            Comment


            • #26
              Originally posted by brk0_0 View Post
              Say that to my Monte Carlo simulation. I never even saw it ending with Python, and took just one minute to run with Julia.
              Tried with PyPy?

              Comment


              • #27
                Originally posted by pininety View Post
                My college was writing for over 3 weeks in C and his program still was not working.
                Noone has been arguing for the ease of programming C. That is very different from C++.
                I use a mix of languages, and ive never understood the idea that python would be so much easier than c++
                static typing is so nice to have. It captures so many bugs at the compiletime instead of failing during runtime.
                On the other hand, running things in interpretive mode is alsso nice. So a bit of pros and cons.d

                Comment


                • #28
                  Originally posted by AnonymousCoward View Post
                  Hey Michael, could you do some JITed language benchmarks in the future? Would be interesting to see how different JIT implementations compare.

                  I think LuaJIT would be the fastest JIT implementation, but it would be better to see actual benchmarks.

                  PS: If you do such comparisons, then do keep in mind that you should pre-compile the source files to their intermediate representations, otherwise implementations where pre-compiling is not required (LuaJIT, V8, PyPy, etc.) would be at a disadvantage vs Java where pre-compiling is required.


                  No Lua, but here's a paper comparing naive implementations of an econometrics algorithm in several languages (not fine-tuned for each platform):



                  Contrary to the smack talk in other posts, Python and the Numba JIT compiler achieved performance of about 1.5x C++ performance in this test.

                  Comment


                  • #29
                    Originally posted by Michael_S View Post
                    The real question is not whether a JIT compiler can match a language that's as close to the bare metal as C or C++. It can't.
                    While I agree with everything else you wrote and thought it was spot-on (using a low-level language as a first option is often a form of premature optimization), I can't agree with the above sentence. It's simply not true from a computer science standpoint. In theory a JIT can achieve better performance since it has more real-time metrics on the performance of the program and can optimize for the specific hardware and instruction set present (especially when compiled programs are often compiled for the 'lowest common denominator" in regards to CPU instruction features). I've seen real-world comparisons where JITed code has beat out compiled code - for instance, both Java and C# beating Delphi in SciMark 2011, and another in which a person tested their algorithm that manipulated image files and Java just edged out the other competition, including Nimrod, which cross-compiles to C++ code.

                    Comment


                    • #30
                      Originally posted by wizard69 View Post
                      I mean really how many Python speed up initiatives are there out there? Maybe it isn't meant to be fast.

                      What is more bothersome is that if they would upgrade to Modern C++ they would benefit greatly and would develop the programming skills required to manage C++. In some ways modern C++ is just as easy to work with as Python.
                      How in the world is C++ "Just as easy to work with as Python"? C++ has a billion special rules and corner cases to the point where you have books about "C++: The Good Parts". Python is designed from the ground up for simplicity and readability. What CPython is to C++ in terms of speed C++ is to Python in terms of ease of use.

                      Comment

                      Working...
                      X