PYC PYO
Not possible

Convert PYC to PYO

Can you convert PYC to PYO?
QUICK ANSWER
Is it possible to convert PYC to PYO?
No - not a direct conversion.

The .pyo extension was removed in Python 3.5 (PEP 488); since then, optimized bytecode is stored as a .pyc file with an opt-1 or opt-2 suffix in the filename. No converter produces .pyo output because the format no longer exists.

No direct path

On this page

Tested on macOS, Windows & Linux
Last verified Oct 2026

More free converters

HEIC, PNG, WEBP, MP3 and more - every tool here is free.

Open the toolbox

Why convert PYC to PYO?

.pyo was Python's optimized bytecode, nearly identical to .pyc but with assert statements removed and optionally docstrings stripped. Python 3.5 folded the optimization level into the .pyc filename, making .pyo redundant and removing it entirely. No Python version since 3.5 reads or writes .pyo files, so a PYC-to-PYO converter has no legitimate purpose.

About these formats

Quality & what to watch

  • To produce optimized bytecode in Python 3.5+, run python -O -m compileall yourscript.py; the result is a .pyc file named with opt-1 in the __pycache__ folder.
  • If you have a .pyo file from a Python 2 or early Python 3 project, you can rename it to .pyc and run it with the matching Python version - the interpreter will load it if the magic number matches.
  • pyo and .pyc were functionally near-identical even before removal, which is exactly why the separate extension was eliminated in Python 3.5.

Frequently asked questions

Is .pyo the same as .pyc?
Functionally yes - the only differences were stripped docstrings and disabled assert statements, which is why the separate extension was removed in Python 3.5.
I have a .pyo file from an old project. Can I still use it?
If you have the matching Python version, you can run it directly or rename it to .pyc; Python 3.5 and later do not create .pyo files but can still execute them.
How do I recover source code from a .pyc or .pyo?
Use decompyle3 or uncompyle6 for Python up to 3.8, or pycdc for Python 3.9 and newer; results are approximate and comments are lost.