Live data from Hacker News

Python-based compiler achieves orders-of-magnitude speedups

news.mit.edu

151–160 of 193 posts

Re: Python-based compiler achieves orders-of-magnitude speedups

#151

Earlier quoted context omitted.

Since I have the world's greatest creative assistant handy, here's what GPT-4 thinks a Kim Kardashian language would look like: Hey dolls, let me introduce you to the Kimmie programming language, it's like totally fab and easy to use! To declare a variable, just use the hashtag symbol and the variable name, like this: #my_var To assign a value to the variable, use the word "like" followed by the value, like this: #my…

Is this an original joke/impression by GPT-4? Either way, this is hilarious.

I copied the response verbatim. I also did a follow-up where it wrote the interpreter as well:

    class KimmieInterpreter:
        def __init__(self):
            self.variables = {}
        
        def interpret(self, code):
            for line in code.split("\n"):
                tokens = line.split()
                if len(tokens) == 0:
                    continue
                if tokens[0] == "#":
                    self.variables[tokens[1]] = None
                elif tokens[0] == "#my_var":
                    self.variables[tokens[1]] = int(tokens[3])
                elif tokens[0] == "OMG":
                    print(tokens[1][1:-1])
                elif tokens[0] == "add":
                    var1 = self.variables[tokens[2]]
                    var2 = self.variables[tokens[3]]
                    result = var1 + var2
                    self.variables[tokens[1]] = result

Re: Python-based compiler achieves orders-of-magnitude speedups

#152
post #105

Earlier quoted context omitted.

I wonder what experienced Common Lisp compiler devs could accomplish if they turned their attention to Python.

There is an implementation of Python in Common Lisp https://clpython.common-lisp.dev/ but I think you probably mean some more lower-level thing

I do: I mean some people with experience making Common Lisp implementations (SBCL, maybe) getting an idea and implementing Python with the same basic concepts they used to implement a Common Lisp compiler.

Re: Python-based compiler achieves orders-of-magnitude speedups

#153

Can we please not? Humanity wasted close to 50 years optimizing compilers for one garbage language. Wasted unimaginable efforts, money and developer hours... and all could've been avoided if the same people dedicated a fraction of those resources to language design. Same thing happened with Java. And now the existence of a well-developed compiler became an argument in its own right in favor of choosing a bad language…

[dead]

Re: Python-based compiler achieves orders-of-magnitude speedups

#154
Disclaimer: developer on Pyston, which could be considered a competitor

My concern is: there have been a few projects already that are, from the outside, more or less the same approach and set of tradeoffs as this. And they haven't been that successful. Given that this is treading familiar ground I would expect some words about how this is different, and the lack thereof makes me a bit skeptical to say this will become successful when others did not.

Re: Python-based compiler achieves orders-of-magnitude speedups

#155

Earlier quoted context omitted.

I must have misunderstood what you were objecting to then, my bad. What claim are they making that is so impossible that it borders on being unethical? I mentioned JIT because it seems to be based on a similar principle at least, that of optimizing things on the programmer's behalf by looking at the program's usage and not just by looking at how to speed up the code generally.

My claim is that there is no additional information that Python provides as opposed to C that would make it faster. And hence, the only conclusion I have is either they have supercharged their compiler for that particular benchmark OR they have chosen to handicap C as once can express the computation in C that emits the same assembly that they lowered to and hence my point on handicapping the C benchmark.

> My claim is that there is no additional information that Python provides as opposed to C that would make it faster

Ok, but that's not what they are claiming - their claim (at least based on what the article is saying) is more about one toolchain vs another, i.e. "if you use our compiler (that takes python code as input) then the resulting executable will run as fast (or possibly faster than) programs created by all the popular compilers (that take C/C++ code as input)." The sales pitch is that they've got magic sauce in their compiler, and you get to use Python as well.

Re: Python-based compiler achieves orders-of-magnitude speedups

#156

Since this is highly incompatible with most python ecosystem right now, may I plug nuitka? https://nuitka.net/index.html It's a compiler for python code that can create stand alone executables, and up to 4 times the speed of the initial code. Best of all, it's extremely reliable, with a high level of support of event the tricky things like the scientic and gui stacks.

> high level of support of event the tricky things like the scientic and gui stacks Could it compile an app that uses Pillow and AggDraw and ReportLab and OpenPyXL with a TKInter GUI into a standalone app I can give to a coworker? That would be extremely useful!

I’ve used Nuitka to package an app that involves Pillow, mupdf, PyQt, and several other libraries, and it handles them with no problem.

Re: Python-based compiler achieves orders-of-magnitude speedups

#158
post #109

Am losing count of all these efforts to rescue Python's performance - they all seem to amount to the same thing: it's not very hard to achieve this if you throw out fundamental aspects that make Python what it is. The premise is always that syntax is the barrier, and that people struggle so much to learn a new syntax that this is what keeps them using Python even though its performance is abysmal. But what if this is…

What is this talk about "rescuing" Python performance? Python does not need to be rescued. Its fast enough. For 90% of applications, you are kidding yourself if you need more speed. These are enhancements on Python, where you want to run stuff even faster on par with other languages.

> What is this talk about "rescuing" Python performance?

Which part don't you like:

That python is relatively slow? https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Or that people are trying to fix its slowness? See the thread you're currently in.

Re: Python-based compiler achieves orders-of-magnitude speedups

#159

Earlier quoted context omitted.

Depends of the work you have to do. If you code a website, fast api and django, the two most popular framework to do so, heavily rely on them to make you productive.

If you code a website, your speed issues probably come from the database layer. Not your Python.

What are you doing to your database? Lol

Most databases I’ve dealt with will happily outstrip Python for a good chunk of the common queries.

Re: Python-based compiler achieves orders-of-magnitude speedups

#160
post #115

Python should just have optional compilation built right into the language. Likewise, modern low level languages should have syntactical conveniences and optional whitespace. It’s 2023. We don’t need to keep having this war.

Scala seems to be taking this route with Scala 3. I’ll definitely be keeping an eye on it. The JVM is very underrated on HN, and I’m far from a Java fanboy (I’m basically a Zig evangelist).

> The JVM is very underrated on HN

I don't like it for my use cases, but whenever I read about it on HN it's supposedly the best-tooled, finest artifact of performance engineering ever built.

Post reply on HN