News for hackers. Stuff that matters.
Re:How the CPython compiler works by basic_bgnr on Thursday September 24, 2020 @11:04AM (#24579273)
Can you point me toward something that's alternative to switch statement for jumping opcodes. How can we speed things up?
Re:How the CPython compiler works by bjoli on Thursday September 24, 2020 @12:46PM (#24580594)
The other comment mentions computed Goto's. I have used those with big success when writing streaming parsers that work per-char (like a typical JSON or csv-parser). I can't remember exactly, but I think switching from a switch statement to computed gotos cut something like 10% from execution time due to better branch predictions in the CPU. That is pretty huge, considering it was a pretty small change to the char dispatch.
Re:How the CPython compiler works by status_quo69 on Thursday September 24, 2020 @11:47AM (#24579758)
Do you mean a switch statement in pure-python that avoids certain opcodes, or a way to avoid executing opcodes in the main interpreter switch statement?