Skip to main content

unsafe-python

Memory-unsafe operations in pure CPython, gated behind safe context managers. No ctypes, no C extensions.

CPython 3.8 - 3.11 only.

Installation

pip install -U unsafelib

Usage

from unsafelib import Unsafe

# All unsafe ops require a context block
with Unsafe() as u:
    # Get heap address of any Python object
    obj = [1, 2, 3]
    print(hex(u.addrof(obj)))  # 0x7f2a1c3d4e80

    # Read/write raw process memory
    mem = u.getmem()
    print(bytes(mem[u.addrof(obj):u.addrof(obj) + 32]))

    # Forge a fake object from an address
    clone = u.fakeobj(u.addrof(obj))
    assert clone is obj

    # Jump to arbitrary address (segfaults)
    u.setrip(0xDEADBEEF)

# Outside the block - raises UnsafeContextError
u.getmem()  # UnsafeContextError: Cannot call 'getmem' outside of an unsafe context.

License

MIT

Metadata

Release files for unsafelib 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 unsafelib 0.1.0
File Size Uploaded Provenance Actions
unsafelib-0.1.0.tar.gz 21.0 kB With provenance Details for unsafelib-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 28.8 kB

Release files / unsafelib-0.1.0.tar.gz

Download URL unsafelib-0.1.0.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
db78534ca1a8c05efa816f2665c6785259ed4a53647c7d64a4d7adc0c6289d07
BLAKE2b-256 checksum
How to use checksums
875c2f24933767050f7aeba84c0fb9f15c352a08a643250202ff6307bed4a4d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

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

Download URL unsafelib-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb5691c0c724f55dd4fa975c15384b14bab16bd7a27b1654773b077d23c27410
BLAKE2b-256 checksum
How to use checksums
28ff9da962bd5a7f37d7af884785013593d42d501fe263696281f4f20ecabcce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Security for unsafelib 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for unsafelib-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

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

0.1.0 This release

2 release files Full 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