SHOW HN: Experimental GCC/GAS inline assembly bridge for Python

sunuhwang1 pts0 comments

sfpy-asm · PyPI

Skip to main content<br>Switch to mobile version

Warning

You are using an unsupported browser, upgrade to a newer version.

Warning

Some features may not work without JavaScript. Please try enabling it if you encounter problems.

Search PyPI

Search

sfpy-asm 0.1.1

pip install sfpy-asm==0.1.1

Copy PIP instructions

Latest release

Released:<br>Jun 28, 2026

Experimental GCC/GAS inline assembly bridge for Python

Navigation

Verified details

These details have been verified by PyPI<br>Maintainers

sunuh

Unverified details

These details have not been verified by PyPI<br>Project links

Homepage

Issues

Repository

Meta

License Expression: MIT

SPDX<br>License Expression

Requires: Python >=3.10

Report project as malware

Project description

sfpy-asm(Segmentation Fault in Python)

Experimental Python bridge for GCC/GAS-style extended inline assembly.

from sfpy import __asm__

result = __asm__(<br>"addq %1, %0",<br>[("+r", 40)],<br>[("r", 2)],<br>["cc"],

assert result == 42

Only __asm__ is exported from sfpy.

API

__asm__(code: str, outputs=None, inputs=None, clobbers=None)

code: GCC extended inline assembly template. GAS syntax is accepted by GCC.

outputs: list of (constraint, value) output operands.

inputs: list of (constraint, value) input operands.

clobbers: list of register/clobber names such as ["rax", "memory", "cc"].

Return value:

no outputs: None

one output: that value

multiple outputs: tuple of values

Supported operand values:

int, bool: native long long

float: native double

str: UTF-8 const char *

bytes, bytearray: byte buffer pointer

any other object: raw PyObject *

Python callables used as inputs: native no-argument callback pointer returning long long

Python variables cannot be mutated through GCC output operands, so output operands are<br>returned instead. For read/write constraints such as "+r", the supplied output value is<br>used as the initial native value.

Callable operands are plain native function pointers. Call them from assembly with<br>call *%N. Because GCC cannot see that call, include the usual caller-saved register<br>clobbers yourself:

def answer():<br>return 42

result = __asm__(<br>"call *%1\nmovq %%rax, %0",<br>[("=r", 0)],<br>[("r", answer)],<br>["rax", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "memory", "cc"],

This package is Linux/WSL-only and requires gcc plus Python development headers at<br>runtime because __asm__ compiles a small shared object for each assembly signature.

Project details

Verified details

These details have been verified by PyPI<br>Maintainers

sunuh

Unverified details

These details have not been verified by PyPI<br>Project links

Homepage

Issues

Repository

Meta

License Expression: MIT

SPDX<br>License Expression

Requires: Python >=3.10

Release history

Release notifications |<br>RSS feed

This version

0.1.1

Jun 28, 2026

0.1.0

Jun 28, 2026

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sfpy_asm-0.1.1.tar.gz<br>(6.0 kB<br>view details)

Uploaded<br>Jun 28, 2026

Source

Built Distribution

Filter files by name, interpreter, ABI, and platform.

If you're not sure about the file name format, learn more about wheel file names.

The dropdown lists show the available interpreters, ABIs, and platforms.

Enable javascript to be able to filter the list of wheel files.

Copy a direct link to the current filters

Copy

File name

Interpreter

Interpreter<br>py3

ABI

ABI<br>none

Platform

Platform<br>any

sfpy_asm-0.1.1-py3-none-any.whl<br>(5.8 kB<br>view details)

Uploaded<br>Jun 28, 2026

Python 3

File details

Details for the file sfpy_asm-0.1.1.tar.gz.

File metadata

Download URL: sfpy_asm-0.1.1.tar.gz

Upload date:<br>Jun 28, 2026

Size: 6.0 kB

Tags: Source

Uploaded using Trusted Publishing? No

Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for sfpy_asm-0.1.1.tar.gz

Algorithm<br>Hash digest

SHA256

db1fbc55819283c3cfe2cc211e1b48a29e7899f21f297bb88aeb564036cb5f2f

Copy

MD5

3410239ea90007b01d5d0a4bd8c5d3ad

Copy

BLAKE2b-256

c4572885188b82735700a2c3f9be676439554a6c6b00dc5fad447822c6d8043a

Copy

See more details on using hashes here.

File details

Details for the file sfpy_asm-0.1.1-py3-none-any.whl.

File metadata

Download URL: sfpy_asm-0.1.1-py3-none-any.whl

Upload date:<br>Jun 28, 2026

Size: 5.8 kB

Tags: Python 3

Uploaded using Trusted Publishing? No

Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for sfpy_asm-0.1.1-py3-none-any.whl

Algorithm<br>Hash digest

SHA256

6b3b014fbaedf1af87b3bf87fa3602d97609772e1e190e15541ff410353ba916

Copy

MD5

6caa978d4a38516539c5bee712e797df

Copy

BLAKE2b-256

9b208b8cd12496012a75b8449257110c2b6c46380ef1db48880e122e9177179d

Copy

See more details on using hashes here.

About PyPI

Contributing to PyPI

Using PyPI

Status:<br>all systems operational

Developed and maintained by the Python community, for the Python community.

Donate today!

"PyPI", "Python Package Index", and the blocks logos are registered...

details python file pypi copy none

Related Articles