Live data from Hacker News

A tail calling interpreter for Python (already landed in CPython)

blog.reverberate.org

21–30 of 93 posts

Re: A tail calling interpreter for Python (already landed in CPython)

#21
post #4

This does NOT mean Python will get Tail Call Optimization, as Guido cannot be shown The Light, and has decided.

Guido is no longer BDFL though, it's the steering committee that decides.

the steering committee seems way less conservative than Guido, right?

Looking at python from the outside a lot of changes since GvR stepped down seem like stuff he'd not have been fond of.

Re: A tail calling interpreter for Python (already landed in CPython)

#22
post #19

This does NOT mean Python will get Tail Call Optimization, as Guido cannot be shown The Light, and has decided.

It is not an optimization ; it changes program semantics - converts programs that will run out of stack eventually regardless of the amount of available memory (and raise exceptions an the process, for example, which a program might rely on. Either way, semantics are changed) It should only be called Tail Call Elimination.

> converts programs that will run out of stack eventually regardless of the amount of available memory (and raise exceptions an the process, for example, which a program might rely on

https://xkcd.com/1172/

Re: A tail calling interpreter for Python (already landed in CPython)

#23

Will Python ever get fast? Or even _reasonably_ fast? The answer is no, it will not. Instead they'll just keep adding more and more syntax. And more and more ways to do the same old things. And they'll say that if you want "fast" then write a native module that we can import and use. So then what's the point? Is Python really just a glue language like all the rest?

Python is fast enough for a whole set of problems AND it is a pretty, easy to read and write language. I do think it can probably hit pause on adding more syntax but at least everything it adds is backwards compatible. You won’t be writing a 3D FPS game engine in Python but you definitely can do a whole lot of real time data processing, batch processing, scientific computing, web and native applications, etc. before…

> You won’t be writing a 3D FPS game engine in Python

While Eve Online isn’t an FPS, it is an MMORPG written in stackless Python, and seems to be doing OK.

Re: A tail calling interpreter for Python (already landed in CPython)

#24
post #4

Earlier quoted context omitted.

Guido is no longer BDFL though, it's the steering committee that decides.

the steering committee seems way less conservative than Guido, right? Looking at python from the outside a lot of changes since GvR stepped down seem like stuff he'd not have been fond of.

Any examples? The biggest change since Guido stepped down has been the addition of pattern matching, which he was strongly in favour of.

Moreover, Guido is in favour of ongoing addition of major new features (like pattern matching), worrying that without them Python would become a “legacy language”:

https://discuss.python.org/t/pep-8012-frequently-asked-quest...

Re: A tail calling interpreter for Python (already landed in CPython)

#25
post #3

Earlier quoted context omitted.

That's probably one of the more frustrating things about Python. Each release it gets all sorts of questionable new syntax (including the very strange pattern matching "feature" that kind of sucks compared to something like Erlang or Scala), but we never get real useful quality of life improvements for basic functional programming like TCO or multi line lambdas

Python has always been unashamedly imperative, with some functional features entering by slipping through the cracks. The pattern matching thing seemed ok to me when I tried it, but I haven't used it except briefly, since I'm still mostly on Python 3.9. Interestingly, Python has been losing users to Rust. I don't entirely understand that, other than everyone saying how Rust's tooling is so much better.

> Python has been losing users to Rust. I don't entirely understand that, other than everyone saying how Rust's tooling is so much better.

Not to rust, but to Go and C++ for myself. The biggest motivating factor is deployment ease. It is so difficult to offer a nice client install process when large virtual environments are involved. Static executables solve so many painpoints for me in this arena. Rust would probably shine here as well.

If its for some internal bespoke process, I do enjoy using Python. For tooling shipped to client environments, I now tend to steer clear of it.

Re: A tail calling interpreter for Python (already landed in CPython)

#26
post #19

This does NOT mean Python will get Tail Call Optimization, as Guido cannot be shown The Light, and has decided.

It is not an optimization ; it changes program semantics - converts programs that will run out of stack eventually regardless of the amount of available memory (and raise exceptions an the process, for example, which a program might rely on. Either way, semantics are changed) It should only be called Tail Call Elimination.

By that standard, any optimization that changes scaling in any dimension changes semantics, which, well, I’m not saying its wrong, but I would say it is exactly what people looking for optimization want.

Re: A tail calling interpreter for Python (already landed in CPython)

#27

Will Python ever get fast? Or even _reasonably_ fast? The answer is no, it will not. Instead they'll just keep adding more and more syntax. And more and more ways to do the same old things. And they'll say that if you want "fast" then write a native module that we can import and use. So then what's the point? Is Python really just a glue language like all the rest?

Python is fast enough for a whole set of problems AND it is a pretty, easy to read and write language. I do think it can probably hit pause on adding more syntax but at least everything it adds is backwards compatible. You won’t be writing a 3D FPS game engine in Python but you definitely can do a whole lot of real time data processing, batch processing, scientific computing, web and native applications, etc. before…

> If your only metric for a language is speed then nothing really beats hand crafted assembly

Only if you know the micro-architecture of the processor you are running on at great depth and can schedule the instructions accordingly. Modern compilers and vms can do crazy stuff at this level.

> Python is fast enough for a whole set of problems AND it is a pretty, easy to read and write language.

It is definitely easy to read. But speed is debatable. It is slow enough for my workload to start wondering about moving to pypy.

Re: A tail calling interpreter for Python (already landed in CPython)

#28
How does this differ from direct threading interpreters?

It seems like it solves the same problem (saving the function call overhead) and has the same downsides (requires non-standard compiler extensions)

EDIT: it seems the answer is that compilers do not play well with direct-threaded interpreters and they are able to perform more/better optimizations when looking at normal-sized functions rather than massive blocks

http://lua-users.org/lists/lua-l/2011-02/msg00742.html

Re: A tail calling interpreter for Python (already landed in CPython)

#29
post #3

Earlier quoted context omitted.

That's probably one of the more frustrating things about Python. Each release it gets all sorts of questionable new syntax (including the very strange pattern matching "feature" that kind of sucks compared to something like Erlang or Scala), but we never get real useful quality of life improvements for basic functional programming like TCO or multi line lambdas

> we never get real useful quality of life improvements for basic functional programming like TCO or multi line lambdas A lambda can be as big of an expression as you want, including spanning multiple lines; it can't (because it is an expression) include statements, which is only different than lambdas in most functional languages in that Python actually has statements.

> most functional languages

Most popular functional languages I can think of except maybe Haskell has statements!

Re: A tail calling interpreter for Python (already landed in CPython)

#30
post #19

Earlier quoted context omitted.

It is not an optimization ; it changes program semantics - converts programs that will run out of stack eventually regardless of the amount of available memory (and raise exceptions an the process, for example, which a program might rely on. Either way, semantics are changed) It should only be called Tail Call Elimination.

By that standard, any optimization that changes scaling in any dimension changes semantics, which, well, I’m not saying its wrong, but I would say it is exactly what people looking for optimization want.

> By that standard, any optimization that changes scaling in any dimension changes semantics

That doesn't follow. This isn't like going from driving a car to flying an airplane. It's like going from driving a car to just teleporting instantly. (Except it's about space rather than time.)

It's a difference in degree (optimization), yes, but by a factor of infinity (O(n) overhead to 0 overhead). At that point it's not unreasonable to consider it a difference in kind (semantics).

Post reply on HN