{"id":30684189,"url":"https://github.com/interrrp/dementia","last_synced_at":"2025-09-01T20:14:29.501Z","repository":{"id":304499642,"uuid":"1018507557","full_name":"interrrp/dementia","owner":"interrrp","description":"🥴 A blazingly fast Brainfuck interpreter in Python","archived":false,"fork":false,"pushed_at":"2025-07-13T12:51:50.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-13T14:42:22.204Z","etag":null,"topics":["brainfuck","python"],"latest_commit_sha":null,"homepage":"","language":"Brainfuck","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interrrp.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,"zenodo":null}},"created_at":"2025-07-12T12:11:19.000Z","updated_at":"2025-07-13T12:51:53.000Z","dependencies_parsed_at":"2025-07-13T14:42:25.664Z","dependency_job_id":"bb6a0de4-f33b-4781-b2f0-e6d53f4a0b77","html_url":"https://github.com/interrrp/dementia","commit_stats":null,"previous_names":["interrrp/dementia"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/interrrp/dementia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interrrp%2Fdementia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interrrp%2Fdementia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interrrp%2Fdementia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interrrp%2Fdementia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interrrp","download_url":"https://codeload.github.com/interrrp/dementia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interrrp%2Fdementia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273183229,"owners_count":25059812,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["brainfuck","python"],"created_at":"2025-09-01T20:14:28.946Z","updated_at":"2025-09-01T20:14:29.494Z","avatar_url":"https://github.com/interrrp.png","language":"Brainfuck","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dementia\n\nA blazingly fast Brainfuck interpreter written in Python.\n\n## Usage\n\n1. Install [Python](https://python.org/) if you haven't already.\n2. Clone the repository.\n3. `python -m dementia \u003cpath to program\u003e`\n\nExample programs are provided in the [programs](programs) directory.\n\n## Optimizations\n\n\"How is it so fast?\" you may ask. Well, optimizations, of course. How else?\n\n### 1. Process Brainfuck into IR\n\nIdentifies common patterns:\n\n| Pattern    | IR            |\n| ---------- | ------------- |\n| `+++++--`  | `+ 3`         |\n| `\u003e\u003e\u003e\u003e\u003e\u003c\u003c`  | `\u003e 3`         |\n| `[-]`      | `clear`       |\n| `[-\u003c\u003c+\u003e\u003e]` | `transfer -2` |\n\n### 2. Build Python code\n\nTransforms the IR into Python code.\n\n```py\n# +++ (+ 3) gets transformed into this:\ntape[ptr] += 3\n\n# Similarly, \u003e\u003e\u003e (\u003e 3) gets transformed into this:\nptr += 3\n\n# etc...\n```\n\n### 3. Execute Python code\n\nExecute the generated Python code using `exec`.\n\n### 4. Use PyPy (optional, 27x speed boost)\n\nThe performance difference between running this on CPython compared to PyPy is quite huge. On [mandelbrot.b](programs/mandelbrot.b), PyPy offered a 27x speed boost (1m27s vs 3s!).\n\n## License\n\nThis project is licensed under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterrrp%2Fdementia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterrrp%2Fdementia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterrrp%2Fdementia/lists"}