Skip to main content

PyFASM64: Universal Python-to-Pure FASM x86_64 Native Compiler

🌐 Language / Язык: English | 🇷🇺 Русский (Russian Documentation)

PyPI - Version GitHub Release PyPI - Downloads PyPI - Python Version CI Conda-Forge Debian Package Python: 3.8 - 3.16 No-GIL: 3.13t - 3.16t Targets: Windows | Linux | macOS | DLL Backend: Flat Assembler x64 License: MIT


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]

Highlights in v2.0.0 (Next-Generation Milestone)

  • 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 type aliases (type Vector = list[int]) and generic functions/classes (def f[T](x: T):).
    • High-performance SIMD/scalar math.sumprod(p, q), chunking with itertools.batched(seq, n), and zero-overhead os.cpu_count().
    • Compile-time version folding: expressions like sys.version_info >= (3, 14) evaluate during compilation, pruning dead branches before emitting machine code.
  • 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, and sys.byteorder.
    • sys._is_gil_enabled() natively returns 0.
  • Beautiful Terminal Documentation:
    • Built-in pyfasm docs terminal renderer with auto-aligned box-drawing tables, framed code blocks, and clean typography.
  • Expanded CLI Flags:
    • Added --gui / -w (Win32 GUI subsystem), --console / -c (console subsystem), --python-version / --py-ver, --optimize / -O, and --verbose / -v.
  • 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.

What's New in v0.1.14: FASM Modern SDK Integration

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):

  1. 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 INCLUDE environment variable setup required.
  2. 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.
  3. 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.
  4. Built-in Interactive Documentation:
    • View English documentation: pyfasm docs
    • View Russian documentation: pyfasm docs --ru
    • Open documentation in markdown viewer/browser: pyfasm docs --open

Quickstart

1. Installation

# Recommended with uv:
uv add pyfasm64

# Or using standard pip:
pip install pyfasm64

2. Five-Second Compilation

Create a Python script hello.py:

def main() -> int:
    name: str = "World"
    print(f"Hello, {name}! Compiled with PyFASM64.")
    return 0

Compile and run directly to a 2.5 KB native binary:

uv run pyfasm64 compile hello.py --run

Command-Line Interface (pyfasm64 / pyfasm)

Both pyfasm64 and pyfasm CLI commands are available:

pyfasm64 compile

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

Auxiliary Commands

  • 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.

Supported Ecosystem & Features

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

Platform Architecture Comparison

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

Performance Benchmarks

Tested on AMD Ryzen / Intel Core x86_64:

Benchmark CPython 3.12 PyPy 3.10 (JIT) PyFASM64 Native x64 Speedup vs CPython
Fibonacci ($N=40$) 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

Verification & Testing

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).

Documentation

Comprehensive architecture, language, and CLI documentation is available in docs/:


Community & Support


License

This project is licensed under the MIT License.

Metadata

Release files for pyfasm64 2.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfasm64 2.3.4
File Size Uploaded Provenance Actions
pyfasm64-2.3.4.tar.gz 2.2 MB Without provenance Details for pyfasm64-2.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyfasm64 2.3.4
File Interpreter ABI Platform Actions
pyfasm64-2.3.4-py3-none-any.whl Python 3 none any Details for pyfasm64-2.3.4-py3-none-any.whl

Total release size: 3.7 MB

Release files / pyfasm64-2.3.4.tar.gz

Download URL pyfasm64-2.3.4.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
838fd18769165f899adb35734f392251868c6ebbcd84c14563c2aeba7c962b37
BLAKE2b-256 checksum
How to use checksums
e54078d99e9dcaecb63cedb23916c0d6654090e023f2e1f0e9dbd39aadb09ece
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pyfasm64-2.3.4-py3-none-any.whl

Download URL pyfasm64-2.3.4-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
af6875067cf46a15105637454615d030d5ad2e56dac19f346732aa3002d95c21
BLAKE2b-256 checksum
How to use checksums
48239dc348804ad2280e3c96412cdb83fa01d05f15d7f2601774e2a4b9d3ddcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pyfasm64 2.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.3.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page