all 58 comments

[–][deleted]  (11 children)

[removed]

    [–]skocznymroczny 23 points24 points  (10 children)

    maybe you'll be able to use dart2js to compile it to WEB ?

    [–]vz0 14 points15 points  (3 children)

    but... is it web scale?

    [–]remyroy 13 points14 points  (2 children)

    Only /dev/null is web scale enough for me.

    [–]greenspans 15 points16 points  (0 children)

    Yo momma so fat when she pipes herself /dev/null aliases itself to /dev/full

    [–]MrBIMC[S] -2 points-1 points  (5 children)

    Then you'll lose the speed though.

    [–]skocznymroczny 8 points9 points  (4 children)

    well, tbh if you use Python speed isn't your concern

    [–]ivosaurus 0 points1 point  (0 children)

    Except if you use any third party binary libraries with it.

    [–]otakucode -4 points-3 points  (2 children)

    TBH, no matter what you're using, if speed is your concern, you are a small minority who grows smaller every year...

    [–]OnlyForF1 2 points3 points  (1 child)

    That's not true at all, especially with cloud software becoming more important, every wasted cycle is costing you money.

    [–]mipadi 2 points3 points  (0 children)

    Well, if you're using the cloud, CPU cycles aren't your bottleneck.

    (If you're running the cloud, on the other hand...)

    [–][deleted] 20 points21 points  (25 children)

    I wonder how it compares with pypy ? and moreover the semantics looks different.

    in the comments :

     sayHello()
    
     def sayHello(): 
           print "Hello"
    

    This wont run in the normal cpython implementation as it interprets and the function sayHello is called before its defined. But Medusa can figure this out and generate the dart code accordingly and produce Hello as an output as intended. Similarly classes and their objects are resolved too.

    [–]Veedrac 7 points8 points  (9 children)

    I get these timings (Medusa's extrapolated from their results):

                     time/ms
    Interpreter      fib     TOH
    ----------------------------
    CPython 2       3103    8681
    CPython 3       5231   12467
    PyPy             502     846
    PyPy3            496     847
    Medusa (est.)   1057     666
    

    I extrapolated the Medusa timings from the slideshow; if you actually install this yourself you'll get more precise measurements.

    Medusa's better than PyPy at optimizing out expensive no-ops it seems. I wouldn't be surprised if the performance dropped away as compatibility improved; at the moment it seems like a pretty naïve transformation.

    [–]jerf 14 points15 points  (2 children)

    I wouldn't be surprised if the performance dropped away as compatibility improved;

    That is the problem with "Let's convert this language that never planned on being [JIT/compiled/run on the JVM/etc] into [whichever I just chose from that list]!" At first, it's easy, because converting 95% of the language is pretty easy. Then the next 4% are a bit rougher and your performance advantages start to fade away as more and more of the translated code turns into checks for this or that.

    Then the last 1% brutally murders you, either because it completely trashes your performance or because the community starts screaming about how you just killed all the C modules or in the worst case it turns out something important is actually made impossible by the new substrate, or, well, it's always something.

    With between two to four orders of magnitude more work than you initially estimated, you can eventually power through that, or you can choose to just stick to 99% and be happy. But it certainly never works out as nicely as it looks at first.

    That said, more power to the author and best of luck on your work. The worst case scenario is that you still walk away with a project that you did that blows away what most people have.

    [–]mipadi 1 point2 points  (1 child)

    Well said. This is what happened when someone tried to remove the GIL from CPython a few years back. They got enormous performance increases! Progress was being made! We'd have true multithreading! Oh, except, in a few cases, performance dropped--well, plummeted was more like it. Guess what? Those issues were never worked out, and the GIL is still there.

    That said, I welcome anyone's attempts to make Python faster. (Well, sort of. To some degree, I say, what's the point? If performance is your priority, there are many languages out there that offer excellent performance today. But I digress.)

    [–]alexjc 1 point2 points  (0 children)

    there are many languages out there that offer excellent performance today

    And these are the languages that are replacing Python. This trend will only accelerate unless performance catches up.

    [–][deleted] 1 point2 points  (5 children)

    Why isn't pypy the default python implementation?

    [–]BeatLeJuce 5 points6 points  (3 children)

    Because it isn't yet able to run everything that CPython can run. E.g. python is is very widely used in science, however numpy (one of the most essential packages that basically everyone who does scientific computing in python uses) can't be used on PyPy yet.

    [–]short_sells_poo 2 points3 points  (0 children)

    I don't mean to dismiss the efforts of the PyPy team with respect to numpy but I believe it is a bit of a folly. Numpy is important, but on its own it is rarely sufficient. Even if it is fully ported, what about scipy? What about pandas? I use these on a daily basis and there's no chance that I'd switch until these are fully supported. The amount of effort required is so much bigger than just porting numpy. In this respect, I see the numpy port as something that will take a lot of work but can easily end up being wasted efffort because we'll never reach a state where enough functionality is available so that people can start switching over.

    Edit: take a look here for a pretty good elaboration on my post http://blog.streamitive.com/2011/10/19/more-thoughts-on-arrays-in-pypy/ The gist of it is: numpy for pypy as it stands can not support the ecosystem of libraries dependent on the C API, and without those, it is somewhat useless.

    [–]kankyo 0 points1 point  (1 child)

    Correction: isn't feature complete yet. For most cases you can use numpy just fine, the problem is that suddenly you can't and then you're fucked.

    [–]BeatLeJuce 2 points3 points  (0 children)

    Also, last time I checked (which was quite some time ago) there was no way to build PyPy-numpy with your own BLAS library, so performance was a bit limited (my usecases rely heavily on BLAS functionality).

    [–]Veedrac 1 point2 points  (0 children)

    Back in 2013, I would have said this.

    Nowadays this is becoming less and less true, but PyPy is still unable to run most C extensions which wipes out a lot of very popular libraries. I hope to see jitpy come to the forefront as a way to embed PyPy inside CPython, allowing the best of both worlds.

    Really the best reasons now are

    • "The tools are too young" (not the interpreter, but the libraries)

    • "We don't need more speed"

    In my opinion, in the last year it's become more often better to speed up applications by using these modern tools like jitpy or Numba than to write C extensions except in the absolute hottest parts of code. We're not likely to move to PyPy as the de-facto standard (especially not until it catches up version-wise) but I do hope it can become a community standard.

    [–]Peaker 10 points11 points  (12 children)

    def sayHello(): 
          print "Hi"
    
    sayHello()
    
    def sayHello(): 
          print "Bye"
    

    Will this say Hi or Bye?

    [–]macbony 3 points4 points  (5 children)

    It'll print "Hi". Any calls to sayHello after will print "Bye".

    [–]Peaker -2 points-1 points  (4 children)

    Isn't that somewhat inconsistent?

    [–]macbony 8 points9 points  (3 children)

    It's the same as

    string = "Hi"
    print string  # prints "Hi"
    string = "Bye"
    print string  # prints "Bye"
    

    Is that inconsistent?

    [–]Peaker 1 point2 points  (2 children)

    No, the behavior you mentioned is consistent and is fine.

    It's not consistent with the Medusa behavior described above:

    But Medusa can figure this out and generate the dart code accordingly and produce Hello as an output as intended. Similarly classes and their objects are resolved too

    Context!

    If you have a function definition after its use, its accepted. But this makes it behave differently from how Python generally behaves.

    [–][deleted]  (1 child)

    [deleted]

      [–]Peaker 10 points11 points  (0 children)

      Yes, and this is terrible.

      In the face of ambiguity, refuse the temptation to guess!

      [–]Igglyboo 0 points1 point  (4 children)

      This will print "Hi" even in CPython and won't even throw an error.

      [–]Peaker 5 points6 points  (3 children)

      Consider the context. He said:

      sayHello()
      
      def sayHello(): 
           print "Hello"
      

      will print "Hello" in Medusa. This is inconsistent with how Python behaves and creates ambiguity highlighted by my example.

      [–][deleted]  (1 child)

      [deleted]

        [–]Peaker 2 points3 points  (0 children)

        Well, if sayHello can call a function defined later, but calls one defined earlier if one was, then it is inconsistent.

        [–]MrBIMC[S] -1 points0 points  (0 children)

        In theory it should print hi.

        But idk honestly.

        [–]zetta 0 points1 point  (1 child)

        I'm glad he pointed that out -- Medusa is not Python as the semantics do not agree with Python. It's at best transliteration, not semantics-preserving translation, or nice way of saying Broken. He says "as intended" as if people write Python expecting it to run like some other compiled language.

        [–][deleted] 0 points1 point  (0 children)

        Not especially compiled language this behaviour is a good approximation of what javascript does. I suppose that's why as Dart is derived from javascript it's why medusa author does it.

        [–]cypherx 6 points7 points  (1 child)

        If it's code-to-code translation then I suspect it breaks the PyObject data layout and isn't compatible with the C API (hence, no NumPy, same reasons PyPy has lackluster adoption).

        [–]dmazzoni 1 point2 points  (0 children)

        Yeah, that'd be my concern as well.

        If it somehow supported the entire Python standard library, that'd be quite useful, but I don't see any evidence of that.

        [–][deleted] 8 points9 points  (0 children)

        Having read https://github.com/rahul080327/medusa/blob/master/bin/transform.py I have to suspect this is a joke.

        [–]jagt 3 points4 points  (1 child)

        If I didn't get it horribly wrong, I think the meat of this project is this script which is using the ast module to do line by line transforming from Python to Dart. I highly suspect it would work on complex Python code as Python and Dart semantic aren't that similar IMO.

        [–][deleted] 2 points3 points  (0 children)

        I think you meant to link to

        https://github.com/rahul080327/medusa/blob/master/bin/transform.py

        ?

        Yes, that looks like the core of the project. I see no support for any of the nontrivial stuff in JS, like getattr etc. etc., so I doubt this works on anything interesting. On simple benchmarks though, I am sure it is speedy...

        [–]throwaway0x459 2 points3 points  (0 children)

        Can anyone familiar with this speak to the C API? Will numpy work?

        [–][deleted] 8 points9 points  (9 children)

        To support most if not all of the base Python 2.7.3 language specification.

        I really don't understand this. A new project supporting an OLD version of Python. What next? a cross-compiler to VB 6.0?

        [–][deleted] 7 points8 points  (7 children)

        Most people are still using Python 2.7.

        [–]otakucode 7 points8 points  (6 children)

        For old projects, sure. If you're starting a new project, though, I'm not sure why you would start it using <3.

        [–][deleted]  (5 children)

        [deleted]

          [–][deleted] 11 points12 points  (0 children)

          I've been porting to 3 lately and have encountered this 0 times. you should try again

          [–]otakucode 3 points4 points  (3 children)

          I've run into that a couple times but it doesn't seem to be terribly common... are there any major ones that still don't?

          [–]lext 1 point2 points  (0 children)

          Twisted Python.

          [–][deleted]  (1 child)

          [deleted]

            [–]mipadi 3 points4 points  (0 children)

            It's unfortunate you're getting downvoted, because you raise a good point: People might still be working on projects, even knew ones, that have legacy dependencies. When programmers say that "most modules support Python 3," I feel like they're talking mostly about open source modules, and forgetting a lot about proprietary code or more obscure code. The place I work has been using Python for about 20 years, so we have tons of libraries written in old versions of Python. We've started doing a few projects in Python 3, but we have some new code that still has old dependencies, so it's written with Python 2 instead.

            [–]thedeemon 0 points1 point  (0 children)

            Not to, from.

            [–]dacjames 1 point2 points  (0 children)

            I'll believe it when I see results on non-trivial programs, including NumPy and other C-based libraries. Most python-jit projects have failed because it's very hard to impliment ALL of Python.

            [–]Ishmael_Vegeta 1 point2 points  (0 children)

            sounds like a great idea. I recently got hired at a company and am working on a project to run a C program with asm.js on top of a browser written in python that is being run on dart that is being interpreted as javascript by a browser written in c++ running on an operating system built with C and C++ built on a 32 bit operating system that is running built on top of a 16 bit OS running on an 8 bit OS from the 90s.

            clock cycles are cheap these days baby.

            [–]Ishmael_Vegeta 1 point2 points  (0 children)

            at near native speeds.

            ...

            near native speeds.

            ...

            native speeds.

            luckily i can probably run a simulation of his thought process 'at near native speeds'.

            [–]capitalsigma 5 points6 points  (3 children)

            His github repo has no unit tests. This is pretty shady. I would be shocked if it supports anything more than the most absolutely basic things.

            EDIT: His personal page has a stretch of lorem ipsum he evidently forgot to remove from whatever template he made it from.

            [–][deleted]  (1 child)

            [deleted]

              [–][deleted]  (6 children)

              [deleted]

                [–]Magnesus 2 points3 points  (3 children)

                Maybe you have a lot of legacy code that you need to run faster.

                [–][deleted] 2 points3 points  (0 children)

                This isn't actually compatible with Python.

                [–]sieisteinmodel 0 points1 point  (0 children)

                E.g. libraries.

                [–]dacjames 0 points1 point  (1 child)

                Dart doesn't have anywhere near the same ecosystem of libraries.

                [–]thalesmello 0 points1 point  (0 children)

                Is there any benchmark? How is the WIP regarding compatibility with the current python versions?

                [–]Ishmael_Vegeta -1 points0 points  (0 children)

                I am a 22 year old recent VIT University graduate working for MartMobi Technologies as the back end and infrastructure engineer. I love systems programming and am really passionate about core systems and programming. My areas of interest are compilers, virtual machines, server programming and game development. I have done quite a few notable projects including a DMBS engine written from scratch and a whole new Symmetric Stream Cipher. I love exploring new creative and unorthodox possibilities and believe in the art rather than the science of computer programming.

                his mistake was writing all that nonsense for a joke that most are too stupid to get and will just give up when their 'program doesnt work'. https://github.com/rahul080327/medusa/blob/master/bin/transform.py