{"id":19210285,"url":"https://github.com/glubs9/bytecodemacro","last_synced_at":"2026-01-04T09:48:12.147Z","repository":{"id":57416739,"uuid":"369034889","full_name":"Glubs9/bytecodemacro","owner":"Glubs9","description":"a python library that exposes the python bytecode to allow for run time modifications of python","archived":false,"fork":false,"pushed_at":"2021-06-05T06:43:42.000Z","size":376,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-02T10:35:40.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Glubs9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributinginformation.txt","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-20T00:26:27.000Z","updated_at":"2022-08-28T03:53:10.000Z","dependencies_parsed_at":"2022-09-19T08:10:47.420Z","dependency_job_id":null,"html_url":"https://github.com/Glubs9/bytecodemacro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glubs9%2Fbytecodemacro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glubs9%2Fbytecodemacro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glubs9%2Fbytecodemacro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glubs9%2Fbytecodemacro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Glubs9","download_url":"https://codeload.github.com/Glubs9/bytecodemacro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245136348,"owners_count":20566586,"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":[],"created_at":"2024-11-09T13:35:37.322Z","updated_at":"2026-01-04T09:48:12.114Z","avatar_url":"https://github.com/Glubs9.png","language":"Python","readme":"# bytecode macro lib\nexposes (a slightly modified version of) the bytecode of a function to allow for run-time modification of python syntax.\n\n# how to use\nfor a description of how to use and install the program, please go to the docs folder on the github (https://github.com/Glubs9/bytecodemacro).\n\n# cool example to get you excited\nthis is a cool example to get you excited with what this library could do and the fun you can have\ndoing it.\n\n```python\ndef goto(tups):\n    ret = []\n    for n in tups:\n        inst, arg = n\n        if inst == \"LOAD_CONST\" and len(arg) \u003e 6 and arg[1:5] == \"goto\":\n            ret.append((\"JUMP_ABSOLUTE\", arg[6:-1]))\n        elif inst == \"LOAD_CONST\" and len(arg) \u003e 2 and arg[-2] == \":\":\n            ret.append((\"LABEL\", arg[1:-2]))\n        else:\n            ret.append(n)\n    return ret\n\n@macro(goto)\ndef f():\n    n = 0\n    while n \u003c 10:\n        if n \u003e 5:\n            _ = \"goto exit\"\n        print(n)\n        n+=1\n    _ = \"exit:\"\nf() #prints 1 2 3 4 5 !\n```\n\nplease have fun writing your own macros! or just have fun looking at\nthe examples in docs/examples.py in the github\n\n# basic installation\nplease read through install.txt for requirements but if you just want to get it installed before\nlooking through the library the comamnd is.  \n```\npython3 -m pip install bytecodemacro\n```\n\n# todo\n\t- add error / semantics checking for the returned bytecode (maybe)\n\t- order examples.py by ease of understanding\n\t\t- so the easy ones to read like constant and add_arg are at the top but the ones\n\t\t\tthat are harder like cloop or join are at the bottom\n\t- add continuations to examples.py\n\t- fix walrus in examples\n\t- test and then handle encountering the extended arg instruction in the uncompile package\n\t- i am also still lost on closures and co_freevars\n\t- printing a string also prints the \"\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglubs9%2Fbytecodemacro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglubs9%2Fbytecodemacro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglubs9%2Fbytecodemacro/lists"}