sfpy-asm 0.1.1

pypi.org · 2026-06-28 · by Long Nguyen ·generic
Experimental GCC/GAS inline assembly bridge for Python

sfpy-asm 0.1.1

Experimental GCC/GAS inline assembly bridge for Python

Project description

[](https://pypi.org/project/sfpy-asm/0.1.1/#user-content-sfpy-asmsegmentation-fault-in-python)sfpy-asm(Segmentation Fault in Python)

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

from sfpy import _asm_

result = _asm_( "addq %1, %0", [("+r", 40)], [("r", 2)], ["cc"], )

assert result == 42

Only `_asm_` is exported from `sfpy`.

[](https://pypi.org/project/sfpy-asm/0.1.1/#user-content-api)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 returned instead. For read/write constraints such as `"+r"`, the supplied output value is used as the initial native value.

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

    def answer(): return 42

    result = _asm_( "call *%1\nmovq %%rax, %0", [("=r", 0)], [("r", answer)], ["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 runtime because `_asm_` compiles a small shared object for each assembly signature.

    Project details

    Release history Release notifications | 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(6.0 kB view details)

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

    Copy a direct link to the current filters [](https://pypi.org/project/sfpy-asm/0.1.1/#files)Copy

    File name

    Interpreter

    ABI

    Platform

    sfpy\_asm-0.1.1-py3-none-any.whl(5.8 kB view details)

    Uploaded 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: 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 | 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: 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 | Hash digest | | | ------------------------------------------- | ---------------------------------------------------------------- | ----------- | | | SHA256 | 6b3b014fbaedf1af87b3bf87fa3602d97609772e1e190e15541ff410353ba916 | Copy | | | MD5 | 6caa978d4a38516539c5bee712e797df | Copy | | | BLAKE2b-256 | 9b208b8cd12496012a75b8449257110c2b6c46380ef1db48880e122e9177179d | Copy | |

See more details on using hashes here.

pypi.org · 12 images · 54 links

Comments (0)

No comments yet