
# cdis - a *consistent* Python disassembler
## Important
The `cdis` bytecode format will not be considered stable until the `1.0.0` release.
The `0.x.y` releases may have breaking changes in both the bytecode and the API exposed.
## What is it?
*cdis*, pronounced "see this", is a Python disassembler that produce consistent results across Python versions.
CPython bytecode is neither forward or backwards compatible, so it outputs bytecode for the "cdis Virtual Machine",
which when executed, has the exact same behaviour as CPython's bytecode.
## Why would I use it?
- To write a Python compiler to any language of your choice
- To determine what symbols a function uses
- As a compiler target to generate Python code from another language
## Known differences with CPython
- Different behaviour of `locals()` inside list comprehensions.
In particular, we use a synthetic variable for the iterator variable
instead of reusing the name.
[CPython changed the behaviour of `locals()` in list comprehension
in 3.12](https://docs.python.org/3/whatsnew/3.12.html#pep-709-comprehension-inlining),
so this is undefined behaviour.
- Different behaviour of when match variables are bound.
Technically, [Python allows binding even when subpatterns fail](https://docs.python.org/3/reference/compound_stmts.html#overview).
That being said, CPython does appear to have consistent behaviour of delaying
binding until all subpatterns succeed.
As such, a future version of `cdis` will probably match
CPython behaviour.
## Missing features
- Using non-constant except types. (Planned)
- Async for (Planned)
- Async with (Planned)
- Generator comprehensions (list, dict and set comprehensions are supported) (Planned)
- Defining classes within functions (Planned)
- User customizable optimization passes (Planned)
- User customizable VM tracer (Planned)
- A guide on how to actually use `cdis` (Planned).
# Run tests
Install test dependencies
```shell
pip install "pytest>8" "coverage" "tox"
pip install -e .
```
Run tests on current python version
```shell
pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "cdis",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "cdis, code analysis, code generation, dis, disassembly",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/a7/63/1cbbdd1c0e9416a5408db8f811b9b2bc522fcf19f8240675694d59641c16/cdis-0.0.0a0.tar.gz",
"platform": null,
"description": "\n\n# cdis - a *consistent* Python disassembler\n\n## Important\n\nThe `cdis` bytecode format will not be considered stable until the `1.0.0` release.\nThe `0.x.y` releases may have breaking changes in both the bytecode and the API exposed.\n\n## What is it?\n\n*cdis*, pronounced \"see this\", is a Python disassembler that produce consistent results across Python versions.\nCPython bytecode is neither forward or backwards compatible, so it outputs bytecode for the \"cdis Virtual Machine\",\nwhich when executed, has the exact same behaviour as CPython's bytecode.\n\n## Why would I use it?\n\n- To write a Python compiler to any language of your choice\n- To determine what symbols a function uses\n- As a compiler target to generate Python code from another language\n\n## Known differences with CPython\n\n- Different behaviour of `locals()` inside list comprehensions.\n In particular, we use a synthetic variable for the iterator variable\n instead of reusing the name.\n [CPython changed the behaviour of `locals()` in list comprehension\n in 3.12](https://docs.python.org/3/whatsnew/3.12.html#pep-709-comprehension-inlining),\n so this is undefined behaviour.\n- Different behaviour of when match variables are bound.\n Technically, [Python allows binding even when subpatterns fail](https://docs.python.org/3/reference/compound_stmts.html#overview).\n That being said, CPython does appear to have consistent behaviour of delaying\n binding until all subpatterns succeed.\n As such, a future version of `cdis` will probably match\n CPython behaviour.\n\n\n## Missing features\n\n- Using non-constant except types. (Planned)\n- Async for (Planned)\n- Async with (Planned)\n- Generator comprehensions (list, dict and set comprehensions are supported) (Planned)\n- Defining classes within functions (Planned)\n- User customizable optimization passes (Planned)\n- User customizable VM tracer (Planned)\n- A guide on how to actually use `cdis` (Planned).\n\n# Run tests\n\nInstall test dependencies\n\n```shell\npip install \"pytest>8\" \"coverage\" \"tox\"\npip install -e .\n```\n\nRun tests on current python version\n\n```shell\npytest\n```",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.0.0a0",
"project_urls": {
"Homepage": "https://github.com/cdis-vm/cdis/tree/main",
"Issues": "https://github.com/cdis-vm/cdis/issues",
"Repository": "https://github.com/cdis-vm/cdis.git"
},
"split_keywords": [
"cdis",
" code analysis",
" code generation",
" dis",
" disassembly"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "657a01873fef2d633824f60a8210b43fe8a228899accd93fd87a0d422463bd65",
"md5": "cd243792ae230224b538c44a3d7c0d7d",
"sha256": "3cc5c3409b10706de6a5d8d92bdf321b8c71521f4199db8053ec31131fc44384"
},
"downloads": -1,
"filename": "cdis-0.0.0a0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cd243792ae230224b538c44a3d7c0d7d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 40926,
"upload_time": "2025-08-14T00:36:04",
"upload_time_iso_8601": "2025-08-14T00:36:04.012960Z",
"url": "https://files.pythonhosted.org/packages/65/7a/01873fef2d633824f60a8210b43fe8a228899accd93fd87a0d422463bd65/cdis-0.0.0a0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a7631cbbdd1c0e9416a5408db8f811b9b2bc522fcf19f8240675694d59641c16",
"md5": "720d6e256a72a73d088927ca1720c2e9",
"sha256": "7036697ffee239e120988cc34fb62cc3e690177614b135a21e1e2ab9614a8ec4"
},
"downloads": -1,
"filename": "cdis-0.0.0a0.tar.gz",
"has_sig": false,
"md5_digest": "720d6e256a72a73d088927ca1720c2e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 55531,
"upload_time": "2025-08-14T00:36:05",
"upload_time_iso_8601": "2025-08-14T00:36:05.345986Z",
"url": "https://files.pythonhosted.org/packages/a7/63/1cbbdd1c0e9416a5408db8f811b9b2bc522fcf19f8240675694d59641c16/cdis-0.0.0a0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-14 00:36:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cdis-vm",
"github_project": "cdis",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cdis"
}