Skip to main content

pyassembler

🚀 The ultimate dynamic compiler by Ilya.

pyassembler is an ultra-fast, zero-overhead hardware JIT bridge that allows you to execute raw x86-64 machine code bytes directly inside the CPU transistors straight from Python! 🪐💻

🔥 Features

  • Zero Overhead: Completely bypasses the Python interpreter slows by executing machine code directly on the silicon!
  • Win32 Kernel Integration: Dynamically allocates memory pages via low-level VirtualAlloc with PAGE_EXECUTE_READWRITE permissions.
  • Hardware Register Control: Execute custom calculations directly in the RAX and RBX general-purpose registers.
  • Enterprise Type Support: Fully equipped with pyassembler.pyi stub files and py.typed for flawless PyCharm autocomplete.
  • Modern Packaging: Managed declaratively via pyproject.toml (PEP 621).

🛠️ Installation

To compile and install the 64-bit static binary directly into your virtual environment, simply run:

pip install .

🕹️ Quick Start

Here is how you can use pyassembler to run hardware-level calculations using CPU stack pushes and pops:

import pyassembler

print("=== Dynamic Hardware Calculation ===")

# Raw x86-64 machine instructions:
# 0x51          -> push rcx         (Save the array pointer to CPU stack)
# 0x48, 0xC7... -> mov rax, 500     (Load 500 into RAX)
# 0x48, 0x05... -> add rax, 300     (Add 300 directly inside the chip)
# 0x48, 0x83... -> sub rax, 23      (Subtract 23, resulting in 777)
# 0x59          -> pop rcx          (Restore the array pointer to RCX)
# 0x48, 0x89... -> mov [rcx], rax   (Safely dump the 777 result back into C-memory)
# 0xC3          -> ret              (Clean return back to Python)
machine_bytes = [
    0x51,
    0x48, 0xC7, 0xC0, 0xF4, 0x01, 0x00, 0x00,
    0x48, 0x05, 0x2C, 0x01, 0x00, 0x00,
    0x48, 0x83, 0xE8, 0x17,
    0x59,
    0x48, 0x89, 0x01,
    0xC3
]

# Fire up the engine!
cpu = pyassembler.RUN(machine_bytes)

print(f"📥 Result from RAX register: {cpu['R12']}")  # Outputs: 777

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pyassembler 0.1.0

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

Source distribution (sdist)

Source distribution for pyassembler 0.1.0
File Size Uploaded
pyassembler-0.1.0.tar.gz 234.1 kB Details

Built distribution (wheel)

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

Total release size: 469.4 kB

Release files / pyassembler-0.1.0.tar.gz

Download URL pyassembler-0.1.0.tar.gz
Size 234.1 kB
Tags Source
SHA-256 checksum
How to use checksums
22211def50f078a6d212850ce64431aaee84203254b1726a4ba8aaf9bee83cfe
BLAKE2b-256 checksum
How to use checksums
df90efef758111cc544c0bfa443cb2dd94c875bffa893a42112d9b6f297f4ad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release files / pyassembler-0.1.0-py3-none-any.whl

Download URL pyassembler-0.1.0-py3-none-any.whl
Size 235.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8b699ce887c1979e8106bd1246156efa56ff0781431949adf72f654a530984d
BLAKE2b-256 checksum
How to use checksums
790bad0ca44b6a4d2e5e735f96f0ae3ddf56bb97178e133c4286c36801fcd17f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release history Release notifications | RSS feed

1.0.0

2 release files

This release

0.1.0 This release

2 release files

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