{"id":20540418,"url":"https://github.com/izo0x90/adding-goto-statement-to-python","last_synced_at":"2025-07-05T16:37:07.881Z","repository":{"id":144726901,"uuid":"420695303","full_name":"izo0x90/Adding-GOTO-statement-to-Python","owner":"izo0x90","description":"Just what it sounds like, decorator that patches function bytecode to allow GOTO's *ROFL*","archived":false,"fork":false,"pushed_at":"2023-04-03T01:50:28.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T04:17:32.521Z","etag":null,"topics":["basic","breaking-bad","bytecode","bytecode-manipulation","cpython","djikstra","donotuse","evil-mode","fun","goto","interpreter","obscure","python","python-internals","python-interpreter","regression","ridiculous","stackmachine","toy-project"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izo0x90.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-24T13:40:38.000Z","updated_at":"2023-04-14T15:20:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"d4b10092-3d19-4e3c-89e7-4521ff977a81","html_url":"https://github.com/izo0x90/Adding-GOTO-statement-to-Python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/izo0x90/Adding-GOTO-statement-to-Python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izo0x90%2FAdding-GOTO-statement-to-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izo0x90%2FAdding-GOTO-statement-to-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izo0x90%2FAdding-GOTO-statement-to-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izo0x90%2FAdding-GOTO-statement-to-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izo0x90","download_url":"https://codeload.github.com/izo0x90/Adding-GOTO-statement-to-Python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izo0x90%2FAdding-GOTO-statement-to-Python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263771931,"owners_count":23509015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basic","breaking-bad","bytecode","bytecode-manipulation","cpython","djikstra","donotuse","evil-mode","fun","goto","interpreter","obscure","python","python-internals","python-interpreter","regression","ridiculous","stackmachine","toy-project"],"created_at":"2024-11-16T01:15:15.976Z","updated_at":"2025-07-05T16:37:07.865Z","avatar_url":"https://github.com/izo0x90.png","language":"Python","readme":"# Adding GOTO statement into Python\n\n[GOTO Considered harmful](https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf) by Edgar Dijkstra\n\n\"Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.\" - That JURASSIC PARK guy\n\nYou guys remember basic.\n\nJust what it sounds like, a decorator that patches the bytecode of a decorated function to allow variable assignments to specific string constants to be treated as GOTO/JUMP statements and LABELS to jump to.\n\nJust in case it needs to be said, yes this is a joke and has no actual uses, nor should anyone use it for anything real other than having fun.\n\n![XKCD Comic, GOTO](https://imgs.xkcd.com/comics/goto.png)\n\nAll relevant code in main.py. \n\nUse:\n```Python\n@goto_mutator            #   \u003c\u003c Decorate func you want to patch GOTOs into with mutator\nsome_func():\n  pass                   #   \u003c\u003c Do regular stuff\n  pass\n  pass \n  x = \"#GOTO_mylabel\"    #   \u003c\u003c This is the goto statement, var name does not matter,\n                         #      statement has to be a string const, \n                         #      starting with keyword #GOTO_ after that label name\n  pass\n  pass\n  pass                     #  \u003c\u003c  Do more regular stuff, of course after patching \n                           #      the goto statemet will skip right over this secion\n                              \n  x = \"#GOTOLABEL_mylabel\" #  \u003c\u003c This is the LABEL we will that will be jumped to\n  pass \n  pass                     #  \u003c\u003c Keep doing stuff \n```\nYou should be able to define as many jumps and labels as desired, mutator will build a map and patch in jumps. \n\nLive REPL demo here:\n[https://replit.com/@HristoGueorguie/Adding-GOTO-statement-to-Python-cue-eveil-laughter](https://replit.com/@HristoGueorguie/Adding-GOTO-statement-to-Python-cue-eveil-laughter).\n\n---\n\nLinks to refs:\n\n[https://rushter.com/blog/python-bytecode-patch/](https://rushter.com/blog/python-bytecode-patch/) - Patching bytecode article by Artem Golubin\n\n[https://www.aosabook.org/en/500L/a-python-interpreter-written-in-python.html](https://www.aosabook.org/en/500L/a-python-interpreter-written-in-python.html) - Python Interpreter in Python article by Allison Kaptur\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizo0x90%2Fadding-goto-statement-to-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizo0x90%2Fadding-goto-statement-to-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizo0x90%2Fadding-goto-statement-to-python/lists"}