{"id":13725295,"url":"https://github.com/snoack/python-goto","last_synced_at":"2026-01-14T08:50:11.966Z","repository":{"id":37493013,"uuid":"42720637","full_name":"snoack/python-goto","owner":"snoack","description":"A function decorator, that rewrites the bytecode, to enable goto in Python","archived":false,"fork":false,"pushed_at":"2021-02-27T23:01:11.000Z","size":38,"stargazers_count":1305,"open_issues_count":15,"forks_count":87,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-09-19T16:17:35.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snoack.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}},"created_at":"2015-09-18T12:27:32.000Z","updated_at":"2025-09-06T21:06:57.000Z","dependencies_parsed_at":"2022-09-15T06:51:21.646Z","dependency_job_id":null,"html_url":"https://github.com/snoack/python-goto","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/snoack/python-goto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoack%2Fpython-goto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoack%2Fpython-goto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoack%2Fpython-goto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoack%2Fpython-goto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snoack","download_url":"https://codeload.github.com/snoack/python-goto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoack%2Fpython-goto/sbom","scorecard":{"id":834709,"data":{"date":"2025-08-11","repo":{"name":"github.com/snoack/python-goto","commit":"acbe736221d2238df3d09beab457d0bb19d05812"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: The Unlicense: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T18:41:01.267Z","repository_id":37493013,"created_at":"2025-08-23T18:41:01.267Z","updated_at":"2025-08-23T18:41:01.267Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-08-03T01:02:18.549Z","updated_at":"2026-01-14T08:50:11.942Z","avatar_url":"https://github.com/snoack.png","language":"Python","readme":"# goto\n\n[![Build Status](https://travis-ci.org/snoack/python-goto.svg?branch=master)](https://travis-ci.org/snoack/python-goto)\n[![Pypi Entry](https://badge.fury.io/py/goto-statement.svg)](https://pypi.python.org/pypi/goto-statement)\n\nA function decorator to use `goto` in Python.\nTested on Python 2.6 through 3.7 and PyPy.\n\n[![](https://imgs.xkcd.com/comics/goto.png)](https://xkcd.com/292/)\n\n## Installation\n\n```\npip install goto-statement\n```\n\n## Usage\n\n```python\nfrom goto import with_goto\n\n@with_goto\ndef range(start, stop):\n    i = start\n    result = []\n\n    label .begin\n    if i == stop:\n        goto .end\n\n    result.append(i)\n    i += 1\n    goto .begin\n\n    label .end\n    return result\n```\n\n## Implementation\n\nNote that `label .begin` and `goto .begin` is regular Python syntax to retrieve\nthe attribute `begin` from the objects with the variable names `label` and\n`goto`. However, in the example above these variables aren't defined.\nSo this code would usually cause a `NameError`. But since it's valid\nsyntax the function can be parsed, and results in following bytecode:\n\n\n```\n  5           0 LOAD_FAST                0 (start)\n              2 STORE_FAST               2 (i)\n\n  6           4 BUILD_LIST               0\n              6 STORE_FAST               3 (result)\n\n  8           8 LOAD_GLOBAL              0 (label)\n             10 LOAD_ATTR                1 (begin)\n             12 POP_TOP\n\n  9          14 LOAD_FAST                2 (i)\n             16 LOAD_FAST                1 (stop)\n             18 COMPARE_OP               2 (==)\n             20 POP_JUMP_IF_FALSE       28\n\n 10          22 LOAD_GLOBAL              2 (goto)\n             24 LOAD_ATTR                3 (end)\n             26 POP_TOP\n\n 12     \u003e\u003e   28 LOAD_FAST                3 (result)\n             30 LOAD_METHOD              4 (append)\n             32 LOAD_FAST                2 (i)\n             34 CALL_METHOD              1\n             36 POP_TOP\n\n 13          38 LOAD_FAST                2 (i)\n             40 LOAD_CONST               1 (1)\n             42 INPLACE_ADD\n             44 STORE_FAST               2 (i)\n\n 14          46 LOAD_GLOBAL              2 (goto)\n             48 LOAD_ATTR                1 (begin)\n             50 POP_TOP\n\n 16          52 LOAD_GLOBAL              0 (label)\n             54 LOAD_ATTR                3 (end)\n             56 POP_TOP\n\n 17          58 LOAD_FAST                3 (result)\n             60 RETURN_VALUE\n```\n\nThe `with_goto` decorator then removes the respective bytecode that has been\ngenerated for the attribute lookups of the `label` and `goto` variables, and\ninjects a `JUMP_ABSOLUTE` or `JUMP_RELATIVE` instruction for each `goto`:\n\n```\n  5           0 LOAD_FAST                0 (start)\n              2 STORE_FAST               2 (i)\n\n  6           4 BUILD_LIST               0\n              6 STORE_FAST               3 (result)\n\n  8           8 NOP\n             10 NOP\n             12 NOP\n\n  9     \u003e\u003e   14 LOAD_FAST                2 (i)\n             16 LOAD_FAST                1 (stop)\n             18 COMPARE_OP               2 (==)\n             20 POP_JUMP_IF_FALSE       28\n\n 10          22 JUMP_FORWARD            34 (to 58)\n             24 NOP\n             26 NOP\n\n 12     \u003e\u003e   28 LOAD_FAST                3 (result)\n             30 LOAD_METHOD              4 (append)\n             32 LOAD_FAST                2 (i)\n             34 CALL_METHOD              1\n             36 POP_TOP\n\n 13          38 LOAD_FAST                2 (i)\n             40 LOAD_CONST               1 (1)\n             42 INPLACE_ADD\n             44 STORE_FAST               2 (i)\n\n 14          46 JUMP_ABSOLUTE           14\n             48 NOP\n             50 NOP\n\n 16          52 NOP\n             54 NOP\n             56 NOP\n\n 17     \u003e\u003e   58 LOAD_FAST                3 (result)\n             60 RETURN_VALUE\n```\n\n## Alternative implementation\n\nThe idea of `goto` in Python isn't new.\nThere is [another module](http://entrian.com/goto/) that has been released\nas April Fool's joke in 2004. That implementation doesn't touch the bytecode,\nbut uses a trace function, similar to how debuggers are written.\n\nWhile this eliminates the need for a decorator, it comes with significant\nruntime overhead and a more elaborate implementation. Modifying the bytecode,\non the other hand, is fairly simple and doesn't add overhead at function\nexecution.\n","funding_links":[],"categories":["Python","Python decorator in the wild"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoack%2Fpython-goto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnoack%2Fpython-goto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoack%2Fpython-goto/lists"}