Skip to content
Python cross-version bytecode library and disassembler
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Administrivia Jun 26, 2018
admin-tools Get ready for release 4.0.1 Apr 30, 2019
appveyor Try appveyor Aug 31, 2017
bin Add format_CALL_function and use it for pypy36 Jun 24, 2019
doc Get ready for release 2.2.2 Aug 26, 2016
test Add IS_PYPY3 to DRY code Apr 30, 2019
test_unit Misc bugs: Jan 19, 2018
xdis Add format_CALL_function and use it for pypy36 Jun 24, 2019
.gitignore Administrivia Apr 16, 2018
.travis.yml Have to drop off 3.3.6 from testing now Aug 19, 2018
COPYING Get ready for release 2.7.0 Mar 7, 2018 Get ready for release 2.7.0 Mar 7, 2018
Makefile Get ready for release 3.8.7 Aug 19, 2018 Get ready for release 4.0.2 Jun 12, 2019
README.rst Fix typo Dec 1, 2018 Ensure pydisasm installs Jun 21, 2019
appveyor.yml Fix appveyor run? May 24, 2018
requirements-dev.txt Remove pytest-qt requirement Jul 2, 2018
requirements.txt Get ready for release 3.1.0 Oct 15, 2016 Get ready for release 3.6.2 Dec 2, 2017
setup.cfg Change ` test` to run `py.test`. Mar 13, 2017 Ensure pydisasm installs Jun 21, 2019
tox.ini Start Python cross disasemble/marshal project May 19, 2016


buildstatus Latest Version Supported Python Versions


Cross-Python bytecode Disassembler and Marshal routines


The Python dis module allows you to disassemble bytecode from the same version of Python that you are running on. But what about bytecode from different versions?

That's what this package is for. It can "marshal load" Python bytecodes from different versions of Python. The command-line routine pydisasm will show disassembly output using Python 3.6 disassembly conventions.

Also, if you need to modify and write bytecode, the routines here can be of help. There are routines to pack and unpack the read-only tuples in Python's Code type. For interoperability between Python 2 and 3 we provide our own versions of the Code type, and we provide routines to reduce the tedium in writing a bytecode file.

This package also has an extensive knowledge of Python bytecode magic numbers, including Pypy and others, and how to translate from sys.sys_info major, minor, and release numbers to the corresponding magic value.

So If you want to write a cross-version assembler, or a bytecode-level optimizer this package may also be useful. In addition to the kinds of instruction categorization that dis offers, we have additional categories for things that would be useful in such a bytecode optimizer.

The programs here accept bytecodes from Python version 1.3 to 3.7 or so. The code requires Python 2.4 or later and has been tested on Python running lots of Python versions.

To install versions for Python before 2.6 install via eggs or use the python-2.4 branch of git in github.


This uses, so it follows the standard Python routine:

pip install -r requirements.txt
pip install -r requirements-dev.txt
python install # may need sudo
# or if you have pyenv:
python develop

A GNU makefile is also provided so make install (possibly as root or sudo) will do the steps above.


make check

A GNU makefile has been added to smooth over setting running the right command, and running tests from fastest to slowest.

If you have remake installed, you can see the list of all tasks including tests via remake --tasks.



./bin/pydisasm -h

for usage help.

As a drop-in replacement for dis

xdis also provides some support as a drop in replacement for the the Python library dis module. This is may be desirable when you want to use the improved API from Python 3.4 or later from an earlier Python version.

For example:

>>> # works in Python 2 and 3
>>> import xdis.std as dis
>>> [x.opname for x in dis.Bytecode('a = 10')]

There may some small differences in output produced for formatted disassembly or how we show compiler flags. We expect you'll find the xdis output more informative though.

See Also

You can’t perform that action at this time.