🌐 Language / Язык: English | 🇷🇺 Русский (Russian Documentation)
PyFASM64 (package: pyfasm64, alias: pyfasm) is an industrial-grade native compiler that translates Python code directly into pure x86_64 Flat Assembler (FASM) machine code. It produces ultra-compact, self-contained standalone executables and shared libraries with zero runtime overhead, no Python virtual machine, and complete elimination of the Global Interpreter Lock (Zero-GIL).
Python Source Code (3.8 – 3.16t)
│
▼ (AST Analysis & Type Propagation)
Semantic Intermediate Representation
│
▼ (Target Selector: Windows / Linux / macOS)
Pure x86_64 FASM Assembly (No libc / No VM)
│
▼ (Bundled FASM Modern SDK Assembler)
Standalone Native Binary (.exe / .elf / .macho / .dll) [~2.5 KB]
- Next-Generation Architecture:
- 100% authentic AST-to-x86_64 compilation pipeline; all historical template fallbacks permanently eradicated.
- Python 3.14 & 3.15 Native Support:
- PEP 695
typealiases (type Vector = list[int]) and generic functions/classes (def f[T](x: T):). - High-performance SIMD/scalar
math.sumprod(p, q), chunking withitertools.batched(seq, n), and zero-overheados.cpu_count(). - Compile-time version folding: expressions like
sys.version_info >= (3, 14)evaluate during compilation, pruning dead branches before emitting machine code.
- PEP 695
- Dynamic Python Version Detection:
- Automatically inspects the host Python environment (e.g. Python 3.15.2 Free-Threaded) and emits tailored constants for
sys.version,sys.version_info,sys.platform, andsys.byteorder. sys._is_gil_enabled()natively returns0.
- Automatically inspects the host Python environment (e.g. Python 3.15.2 Free-Threaded) and emits tailored constants for
- Beautiful Terminal Documentation:
- Built-in
pyfasm docsterminal renderer with auto-aligned box-drawing tables, framed code blocks, and clean typography.
- Built-in
- Expanded CLI Flags:
- Added
--gui/-w(Win32 GUI subsystem),--console/-c(console subsystem),--python-version/--py-ver,--optimize/-O, and--verbose/-v.
- Added
- Modernized Showcase Examples:
- 11 comprehensive, self-contained examples covering OOP, Tkinter, CustomTkinter, FastAPI REST, and Python 3.14/3.15.
- Full Changelog: See CHANGELOG.md for full history.
Starting with v0.1.14, PyFASM64 bundles and deeply integrates the FASM Modern SDK (fasm-modern-sdk v1.73.36 and fasmg v0.0.26):
- Self-Contained Compiler & Headers:
- The official wheel packages contain all required FASM compiler binaries (
FASM.EXE,fasmg.exe,fasm.x64,fasm.darwin,fasm) and standard Win64/Win32 includes (win64a.inc,win32a.inc, equates, macros). - Zero configuration needed: no
INCLUDEenvironment variable setup required.
- The official wheel packages contain all required FASM compiler binaries (
- Modern SDK Include Modules:
ui_fluent.inc: High-performance Modern Fluent Dark UI styling, owner-drawn controls, and smooth rounded cards.json_fast.inc: Zero-allocation SIMD-accelerated JSON parser.net_https.inc: Zero-dependency native WinINet/POSIX sockets HTTPS/TLS network client.data_structures.inc: Dynamic array vectors, string buffers, and hash tables.syntax_color.inc: Lexical tokenization and realtime syntax highlighting engine.
- Unicode & UTF-8 / UTF-16LE Engine:
- Integrated native runtime conversion (
_pyfasm_utf8_to_wide), eliminating Windows Mojibake. - GUI control collision prevention: automatically reuses existing window handles to avoid duplicate controls.
- Integrated native runtime conversion (
- Built-in Interactive Documentation:
- View English documentation:
pyfasm docs - View Russian documentation:
pyfasm docs --ru - Open documentation in markdown viewer/browser:
pyfasm docs --open
- View English documentation:
# Recommended with uv:
uv add pyfasm64
# Or using standard pip:
pip install pyfasm64Create a Python script hello.py:
def main() -> int:
name: str = "World"
print(f"Hello, {name}! Compiled with PyFASM64.")
return 0Compile and run directly to a 2.5 KB native binary:
uv run pyfasm64 compile hello.py --runBoth pyfasm64 and pyfasm CLI commands are available:
pyfasm64 compile <source> [OPTIONS]| Option | Flag | Default | Description |
|---|---|---|---|
<source> |
required | Path to Python file or project directory | |
--output |
-o |
<stem>.<ext> |
Output binary path (.exe, .dll, .elf, .macho) |
--target |
win64 |
Target platform: win64, dll, linux, macos |
|
--gui |
-w, --windowed |
auto | Force Win32 GUI windowed subsystem (no console window) |
--console |
-c |
auto | Force standard console subsystem |
--python-version |
--py-ver |
host | Target Python version (e.g. 3.14, 3.15) |
--optimize |
-O |
False |
Enable assembly peephole optimizations |
--verbose |
-v |
False |
Verbose compilation diagnostics |
--run |
False |
Execute binary immediately upon compilation | |
--icon |
None |
Path to .ico for Windows PE .rsrc icon embedding |
|
--strict |
False |
Promote compiler warnings (W2004–W3001) to hard errors |
|
--export-fasm |
-f |
None |
Export self-contained FASM project with build scripts |
--no-asm |
False |
Clean intermediate assembly files after build |
pyfasm64 check <source> [--strict]: Run syntax, semantic, and type diagnostics without generating machine code.pyfasm64 emit-asm <source> [-o out.asm]: Emit readable, commented x86-64 FASM assembly to stdout or file.pyfasm64 bundle <project_dir> -o App.exe: Bundle entire multi-file project into a single native executable.pyfasm64 clean [--apps | --all]: Clean local build artifacts and global caches.pyfasm64 docs [--ru] [--open]: Interactive documentation viewer in terminal or browser.
| Domain | Supported Features & Libraries | Native Implementation |
|---|---|---|
| Desktop GUI | tkinter, customtkinter, PyQt5, PyQt6, flet |
Native Win32 GDI controls, Dark Fluent styling, dynamic layout, Edit message routing |
| 2D Games | pygame (display, event, draw, Rect, Clock, font) |
Zero-dependency GDI double-buffered graphics backbuffer |
| Web & APIs | fastapi, uvicorn (@app.get, @app.post, JSON payloads) |
High-throughput Winsock2 HTTP/1.1 server, RFC-8259 JSON parser |
| Python 3.14 / 3.15 | TypeAlias, def f[T](), sumprod, batched, cpu_count |
Compile-time branch evaluation, SIMD dot products, PEB processor query |
| Zero-GIL Concurrency | spawn_thread, wait_thread, atomic_add, atomic_sub |
OS kernel threads (CreateThread / sys_clone), hardware lock instructions |
| Object Orientation | class, super(), @property, @staticmethod, @classmethod |
Polymorphic virtual method tables, class tags, reflected dunders (__radd__, etc.) |
| Memory & Buffers | alloc_memory, free_memory, buf[i] |
Direct OS page allocation (VirtualAlloc / sys_mmap), raw pointer indexing |
| Architectural Aspect | Windows x86-64 | Linux x86-64 | Apple macOS x86-64 |
|---|---|---|---|
| Binary Format | PE32+ (PE64) Console / GUI / DLL | ELF64 Executable (Type 3) | Mach-O 64 (MH_MAGIC_64) |
| ABI Calling Convention | Microsoft x64 ABI (Shadow Space) | System V AMD64 ABI | System V AMD64 ABI |
| Kernel Interface | Win32 API (kernel32.dll, user32.dll) |
Direct Linux Kernel Syscalls | Direct Darwin BSD Syscalls |
| External Dependencies | None (OS system libraries only) | Zero libc / Zero glibc | Zero libSystem / Zero dyld |
| Typical Binary Size | ~2.5 KB | ~1.8 KB | ~2.4 KB |
Tested on AMD Ryzen / Intel Core x86_64:
| Benchmark | CPython 3.12 | PyPy 3.10 (JIT) | PyFASM64 Native x64 | Speedup vs CPython |
|---|---|---|---|---|
| Fibonacci ( |
12,450 ms | 620 ms | < 1 ms | > 12,000x |
| Sieve of Eratosthenes (100k) | 185 ms | 18 ms | < 1 ms | > 180x |
| 8-Thread Parallel Counter | 4,210 ms (GIL contention) | 1,840 ms | 47 ms (Zero-GIL) | > 89x |
| Standalone Binary Size | ~35 MB (PyInstaller) | N/A | 2.5 KB | > 14,000x smaller |
Every commit and release is validated across all supported runtimes:
uv run pytest- Compatibility Matrix: CPython 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.16.
- No-GIL Matrix: Free-Threaded Python 3.13t, 3.14t, 3.15t, 3.16t.
- PyPy Matrix: PyPy 3.8 through 3.12.
- Test Suite Status: 100% tests passing (154/154).
Comprehensive architecture, language, and CLI documentation is available in docs/:
- 📘 Documentation Hub — Main index and overview.
- 🚀 Getting Started Guide — Setup, builds, and packaging.
- 📖 Language Reference — Supported syntax, types, and stdlib.
- ⚙️ CLI & Python API — Options, flags, and programmatic API.
- 🔍 Diagnostics & Error Catalog — Compiler error codes (
E1001–E4002). - 🏗️ Architecture & ABI Internals — FASM backend and memory layouts.
- 🇷🇺 Руководство пользователя (Russian Guide) — Документация на русском языке.
- 🐛 Bug Reports & Issues: GitHub Issues
- 💬 Community Discussions: GitHub Discussions
- 🏛️ FASM Community Forum: Flat Assembler Board
- ☕ Donations (USDT TRC-20):
TDVbEdnpgNgoAhNcn1EwXxWHiR3RKLit5P(Verify on TronScan)
This project is licensed under the MIT License.