Live data from Hacker News

Python 3.11 vs 3.10 performance

github.com

281–290 of 460 posts

Re: Python 3.11 vs 3.10 performance

#281

Earlier quoted context omitted.

Dynamic languages like Javascript have solved this problem by essentially caching the resolution of a particular expression that is executed very often. I don't see why this cannot be done in Python.

The expressions are dynamic, so they have to be evaluated every time. Python is excessively dynamic, so it can't (conventionally) be sped up as easily as many other languages unfortunately. Finally some folks are being paid and allowed to be working on it.

I don't buy this. There are many contexts in which a smart JIT compiler can detect that an expression cannot be modified. Especially since, due to the GIL, python code is mostly non-threaded. They just didn't spend enough time to do the hard work that people spent on Javascript.

Re: Python 3.11 vs 3.10 performance

#282

These speedups are awesome, but of course one wonders why they haven't been a low-hanging fruit over the past 25 years. Having read about some of the changes [1], it seems like the python core committers preferred clean over fast implementations and have deviated from this mantra with 3.11. Now let's get a sane concurrency story (no multiprocessing / queue / pickle hacks) and suddenly it's a completely different lang…

Guido stepping away from the language will have a lot of impact on changes that were culturally guided.

[deleted]

Re: Python 3.11 vs 3.10 performance

#283

These speedups are awesome, but of course one wonders why they haven't been a low-hanging fruit over the past 25 years. Having read about some of the changes [1], it seems like the python core committers preferred clean over fast implementations and have deviated from this mantra with 3.11. Now let's get a sane concurrency story (no multiprocessing / queue / pickle hacks) and suddenly it's a completely different lang…

That’s something that has always puzzled me as well. Given the popularity, you’d think Python would have had several generations of JITs by now and yet it still runs interpreted, AFAIK. JavaScript has proven that any language can be made fast given enough money and brains, no matter how dynamic. Maybe Python's C escape hatch is so good that it’s not worth the trouble. It’s still puzzling to me though.

> Maybe Python's C escape hatch is so good that it’s not worth the trouble.

Even if it wasn't good, the presence of it reduces the necessity of optimizing the runtime. You couldn't call C code in the browser at all until WASM; the only way to make JS faster was to improve the runtime.

> JavaScript has proven that any language can be made fast given enough money and brains, no matter how dynamic.

JavaScript also lacks parallelism. Python has to contend with how dynamic the language is, as well as that dynamism happening in another thread.

There are some Python variants that have a JIT, though they aren't 100% compatible. Pypy has a JIT, and iirc, IronPython and JPython use the JIT from their runtimes (.Net and Java, respectively).

Re: Python 3.11 vs 3.10 performance

#284

I just learned today that python is 100x slower than C. I have severely lost respect for python.

C is faster than Python, but it's much more nuanced than saying Python is "100x slower". Try writing a program to open and parse a CSV file line by line in both languages. You'll see why people like Python.

Also, because of FFI, it's not like the two languages are opposed to each other and you have to choose. They can happily work together.

Re: Python 3.11 vs 3.10 performance

#285
post #6

Earlier quoted context omitted.

Python has actually had concurrency since about 2019: https://docs.python.org/3/library/asyncio.html . Having used it a few times, it seems fairly sane, but tbf my experience with concurrency in other languages is fairly limited. edit: ray https://github.com/ray-project/ray is also pretty easy to use and powerful for actual parallelism

I have used asyncio in anger quite a bit, and have to say that it seems elegant at first and works very well for some use cases. But when you try to do things that aren't a map-reduce or Pool.map() pattern, it suddenly becomes pretty warty. E.g. scheduling work out to a processpool executor is ugly under the hood and IMO ugly syntactically as well.

> scheduling work out to a processpool executor is ugly under the hood and IMO ugly syntactically as well.

Are you talking about this example? https://docs.python.org/3/library/asyncio-eventloop.html#asy...

Re: Python 3.11 vs 3.10 performance

#287

Earlier quoted context omitted.

The GIL removal by that guy reverted some of the improvement done by other optimisations, so the overall improvement was much smaller. And most people do care for single-threaded speed, because the vast majority of Python software is written as single-threaded.

> the vast majority of Python software is written as single-threaded. This is a self-fulfilling prophecy, as the GIL makes Python's (and Ruby's) concurrency story pretty rough compared to nearly all other widely used languages: C, C++, Java, Go, Rust, and even Javascript (as of late).

IMHO majority of Python software doesn't use threads because it is easier to write single threaded code (for many reasons), not because of GIL.

Re: Python 3.11 vs 3.10 performance

#288
post #211

Earlier quoted context omitted.

https://github.com/mypyc/mypyc > Mypyc compiles Python modules to C extensions. It uses standard Python type hints to generate fast code. Mypyc uses mypy to perform type checking and type inference.

You can't compile to an executable with mypyc, just native C extensions.

My bad, thanks for clarifying.

Re: Python 3.11 vs 3.10 performance

#289
post #95

Earlier quoted context omitted.

Guido stepping away from the language will have a lot of impact on changes that were culturally guided.

Guido is one of the people leading the current performance efforts.

That's interesting. Thanks.
Post reply on HN