v2.3.7 Latest
Win64 / ELF64 / Mach-O / DLL
Zero VM • Zero-GIL
Bundled FASM 1.73.36 + fasmg
PyFASM64 — Compile Python Directly to Pure x86_64 Assembly
Translates Python AST into self-contained native executables (PE64 .exe, .dll, Linux ELF64, macOS Mach-O) with bundled FASM Modern SDK headers, native OOP/closures, Tkinter/PyQt/Flet/Pygame 2D graphics, FastAPI Winsock2 HTTP server, and FasmExporter standalone assembly export.
📦 1. Installation & Compatibility Matrix
pip install pyfasm64
Both pyfasm64 and pyfasm Python packages and CLI commands are synchronized identically, bundling FASM compiler binaries and Win64/POSIX SDK includes out of the box.
| Runtime / OS | Versions | Status & Mode |
|---|---|---|
| CPython | 3.8 – 3.16 | Full AST compilation & bundler |
| Free-Threaded No-GIL | 3.13t – 3.16t (PEP 703) | Compile-time version folding & native 0-GIL threads |
| PyPy JIT | 3.8 – 3.12 | Compiler & bundler host support |
| Operating Systems | Windows / Linux / macOS | Win64 (.exe/.dll), Linux (ELF64), macOS (Mach-O), MyOS |
⚡ 2. Programmatic Compiler, Exporter & Bundler API
compile_demo.py
from pyfasm import PyFasmCompiler, FasmExporter, PeepholeOptimizer, optimize_fasm_code
compiler = PyFasmCompiler()
asm_text = compiler.compile_source_to_asm(
'''def fib(n: int) -> int:
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
def main() -> int:
print("fib(20) =", fib(20))
return 0
''',
target="win64",
)
optimized = optimize_fasm_code(asm_text)
# Compile directly to standalone executable (~few KB)
ok, exe_path, build_log = compiler.compile_file("app.py", output_binary="app.exe", target="win64")
# Export standalone self-contained FASM source directory (main.asm + INCLUDE + build.bat/build.sh)
FasmExporter.export(optimized, "./exported_asm", app_name="app", target="win64")
💻 3. Command-Line Interface (pyfasm64 / pyfasm)
| Command | Key Options | Description |
|---|---|---|
pyfasm64 compile <src> | -o, --target, --gui/-w, --console/-c, -O, --run, --export-fasm/-f, --strict, --icon | Compile Python script or folder into native binary |
pyfasm64 check <src> | --target, --gui, --strict, -v | Validate Python AST support and diagnostics without assembling |
pyfasm64 emit-asm <src> | -o, --target, --gui, --strict | Generate pure FASM x86_64 assembly listing |
pyfasm64 bundle <dir> | -e/--entry, -o, --console, --include-bin, --include-venv, --dir-mode | Bundle multi-file Python project with assets & venv |
pyfasm64 clean [path] | --all/-a, --apps, --dry-run/-n | Purge compiler cache and unpacked app artifacts |
pyfasm64 docs | --ru, --open | Render bilingual documentation in terminal or viewer |
CLI examples
pyfasm64 compile app.py -o app.exe --target win64 --console -O --run
pyfasm64 compile gui_app.py -o app.exe --gui --icon icon.ico --export-fasm ./fasm_src
pyfasm64 compile server.py --target linux -o server.elf
pyfasm64 bundle ./my_project --include-venv -o release/app.exe
pyfasm64 docs --ru
🛠️ 4. Native Runtime Support & v2.3.7 Fixes
- Pygame 2D (
runtime_win64_pygame.py): Tracks arbitrary Rect variable names (_pygame_rect_vars) across pygame.Rect, get_rect(), move(), inflate(), copy(), and clamp(), with accurate topleft/topright/bottomleft/bottomright/mid*/size coordinate math and offscreen 24bpp alpha blitting. - Desktop UI & Plotting: Native Win32/GDI widgets and Fluent Dark UI bindings for Tkinter, CustomTkinter, Flet, PyQt5/6, plus offscreen/UI Matplotlib charts.
- FastAPI / HTTP Server (
runtime_win64_http.py): Compiles FastAPI routers and HTML/JSON endpoints directly on Winsock2 sockets. - Windows NTFS Clean Checkout (v2.3.7): Removed colliding POSIX case-symlinks in include/API so ADVAPI32.INC, COMCTL32.INC, and COMDLG32.INC stay intact on Windows while dynamic case-folding runs on Linux/macOS.