Result: Recreating Goto in Python: How and Why

Title:
Recreating Goto in Python: How and Why
Authors:
Source:
Proceedings: CITRENZ 2023 Conference, Auckland, 27-29 September. :150-159
Publisher Information:
Unitec ePress, 2024.
Publication Year:
2024
Document Type:
Academic journal Article
DOI:
10.34074/proc.240119
Accession Number:
edsair.doi...........c1c6bf0789432c1b01d24d3f89268f18
Database:
OpenAIRE

Further Information

The Python language has no unrestricted goto statement, but because of Python’s deep introspection capabilities, along with its dynamic nature, an unrestricted goto can be added to the language by rewriting a function’s bytecode at runtime. Two primary use cases for goto in Python are discussed: porting existing historic code to Python while maintaining the existing code’s flavour, and implementing state machines. While theoretically unnecessary, goto can make the first case easier, and the second case faster. An implementation is described and performance tests on an example state machine show using goto is a very fast method of implementing state machines in Python, and existing efforts to port historic code are already using the goto implementation.