Pointer
A Python package that simulates C-style pointers — because Python said it can't have pointers. I took that personally.
Overview
pointer provides a memory simulation layer on top of Python, implementing raw pointer arithmetic, typed memory allocation, and manual memory management — all inside a single bytearray acting as virtual RAM.
How It Works
- A global
_vram(bytearray) serves as the "physical memory". PtrTypeobjects hold an integer address into_vramand interpret the bytes according to aType(short, int, long, char, bool, etc.).Typeis defined viaMainTypes(size in bytes) andModifiedTypes(signed/unsigned).nullptris a sentinel object representing a null pointer.- Memory allocation is tracked via a global
usedset to prevent overlapping.
Core Components
| Class / Enum | Purpose |
|---|---|
MainTypes |
Defines base C types with byte sizes (short=2, int=4, long=8, etc.) |
ModifiedTypes |
Modifiers like unsigned |
PtrType |
A typed pointer that reads/writes from _vram |
nullptr |
Null pointer sentinel |
_vram |
The actual bytearray acting as raw memory |
Usage
Basic Pointer
import pointer as ptr
# Create an integer pointer (default nullptr)
p = ptr.PtrType(ptr.Type(ptr.mat.int))
# Allocate memory (assign a value -> triggers allocation)
p.value = 42
print(p.value) # 42
print(p.ptr) # address in _vram
# Free memory
p.free()
Pointer Arithmetic
p = ptr.PtrType(ptr.Type(ptr.mat.int))
p.value = 100
# Move pointer by N elements (in bytes = N * type.size)
p += 1 # move forward by 4 bytes
p -= 1 # move back by 4 bytes
Array / Multiple Elements
# Create a pointer pointing to 5 consecutive ints
p = ptr.PtrType(ptr.Type(ptr.mat.int), _length=5)
for i in range(5):
p[i] = i * 10
print(p[2]) # 20
Direct Memory Manipulation via _vram
Since _vram is a public bytearray, you can manipulate it directly using ctypes or raw byte operations:
import ctypes
import pointer
# Create a writable buffer that shares memory with _vram
pointer._vram = ctypes.create_string_buffer(1 * 1024 ** 2)
# Now any PtrType reads/writes to this ctypes buffer
p = pointer.PtrType(pointer.Type(pointer.mat.int))
p.value = 999
print(pointer._vram[p.ptr:p.ptr+4]) # raw bytes
Warning: Modifying
_vramdirectly can corrupt existing pointers. Use with caution.
API Reference
PtrType(type, default=nullptr, _length=1)
type: AType(mat, mot)object.default: Initial value (ornullptr)._length: Number of elements (for array-style access).
Properties:
.value→ get/set the value at the current pointer address..ptr→ current integer address (ornullptr).[index]→ array-style element access.
Methods:
.free()→ release allocated memory.__iadd__/__isub__→ pointer arithmetic.
Type(mat, mot=ModifiedTypes.unsigned)
mat: AMainTypesenum member.mot:ModifiedTypes.unsignedor default.
Limitations
- Single global
_vram— no per-process isolation. - No garbage collection; manual
free()required. - Not thread-safe.
- Pointer arithmetic is element-based, not byte-based (unlike real C).
License
MIT — because even fake pointers deserve freedom.
Metadata
Release files for pointer-x 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pointer_x-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for pointer_x-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pointer_x-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pointer_x-0.1.0-py3-none-any.whl |
Total release size: 12.6 kB
Release files / pointer_x-0.1.0.tar.gz
| Download URL | pointer_x-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e05380c0b5d95cda213ed0c8a010d1258e027b2e6cb683881fc17df9be6845a3
|
|
BLAKE2b-256 checksum How to use checksums |
be04ceefde1d33d7b55d33aa971a512d5aa435a63d58dcbf8b93d3800ec56a71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / pointer_x-0.1.0-py3-none-any.whl
| Download URL | pointer_x-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef224a266a12f510ba08e3d9ab0c41a676d51b1e0275b0ce2d64d2762da2c59c
|
|
BLAKE2b-256 checksum How to use checksums |
60328ba5e26cdb5e0f097981dd3408e59587eaaf984a4695df6e7b9dd239da49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for pointer-x 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.
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.