Hacker News new | comments | show | ask | jobs | submit login

There are some changes to ceval in 3.8 that should make it a bit simpler:

  The interpreter loop has been simplified by moving the logic of unrolling the stack of blocks into the compiler. The compiler emits now explicit instructions for adjusting the stack of values and calling the cleaning up code for break, continue and return.
  Removed opcodes BREAK_LOOP, CONTINUE_LOOP, SETUP_LOOP and SETUP_EXCEPT. Added new opcodes ROT_FOUR, BEGIN_FINALLY, CALL_FINALLY and POP_FINALLY. Changed the behavior of END_FINALLY and WITH_CLEANUP_START.
  (Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka in bpo-17611.)
https://docs.python.org/3.8/whatsnew/3.8.html

https://bugs.python.org/issue17611




Wow thanks for the pointer! This is great. I want to move more stuff to compile-time, like name resolution, and moving some control flow to compile time is something I've also wondered about.

I watched a few talks [1] about how C++ exception handling works, and they try to avoid branches/setup blocks in the "happy path". It works a little like longjmp() in C, where you just set the instruction pointer say three function calls down in the stack. But then you have to look up all the exception handlers to run in precomputed tables (which doesn't happen in C). So I wonder if something like that would speed up (my subset of) Python, since exceptions are quite common.

[1] https://www.youtube.com/watch?v=_Ivd3qzgT7U




Applications are open for YC Winter 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: