Lost Your Python Source? -- Get it back!

Lost your Python source files? But still
have the .pyc/.pyo files? Get your sources back! Just send in your
.pyc/.pyo file and get the source code mailed back to you within
hours!

The 'decompyle' service converts Python
byte-code back into equivalent Python source. It accepts byte-code
from any Python version starting with 1.5 up to 2.6

The generated source is very readable: docstrings, lists, tuples
and hashes get pretty-printed. Only the comments are missing. To
ensure the source code is correct, we verify the equivalence of the
generated source by compiling it and comparing both byte-codes.

How good is decompyle?

Our unit-tests include more than 3900 test-patterns. Each of it is
successfully decompiled for all supported versions, both normal (.pyc)
and optimized (.pyo) bytecode. This is a total of about 138,000
test-cases.

Limitations and Known Bugs

Starting with Python 2.5 the compiler does simple constant folding
in expressions. This means '2*8 + 1' will just be stored as '17' in
the bytecode. So decompyle has no chance to restore the constant
exprassion which was typed in. Nevertheless the resulting code is
semantically the same.

The EXTENDED_ARG token is untested (this is a new token for Python
2.0 which is used only if many items exist within a code
object).

Acknowledgement

'decompyle' uses
John Aycock's
generic small languages compiler
'spark'
and his prior work on decompyle.