virtual-allocator
Python allocator for a virtual memory range. This package only implements the allocation of a memory range, the actual memory access must be implemented separately. So no use-after-free errors can be handled.
The allocator implements the allocate, free and resize methods which each return a new MemoryRegion object.
from virtual_allocator import AllocationPolicy, Allocator, MemoryRange
alloc = Allocator(
address=0,
size=256,
block_size=16,
alignment=32,
allocation_policy=AllocationPolicy.BEST_FIT
)
mem_ranges = [alloc.allocate(64) for _ in range(3)]
assert mem_ranges == [
MemoryRange(address=0, size=64, is_free=False, padding=0),
MemoryRange(address=64, size=64, is_free=False, padding=0),
MemoryRange(address=128, size=64, is_free=False, padding=0),
MemoryRange(address=196, size=64, is_free=True, padding=0),
]
alloc.free(mem_ranges[1])
assert mem_ranges == [
MemoryRange(address=0, size=64, is_free=False, padding=0),
MemoryRange(address=64, size=64, is_free=True, padding=0),
MemoryRange(address=128, size=64, is_free=False, padding=0),
MemoryRange(address=196, size=64, is_free=True, padding=0),
]
Allocation policies
The allocator class supports two allocation policies, FIRST_FIT and BEST_FIT.
FIRST_FITallocation allocates new regions into the lowest free regionBEST_FITallocation will allocate new regions into the free region which will create the smallest leftover memory range
Metadata
Release files for virtual-allocator 0.0.3
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 |
|---|---|---|---|---|
| virtual_allocator-0.0.3.tar.gz | 28.2 kB | Without provenance | Details for virtual_allocator-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| virtual_allocator-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for virtual_allocator-0.0.3-py3-none-any.whl |
Total release size: 33.8 kB
Release files / virtual_allocator-0.0.3.tar.gz
| Download URL | virtual_allocator-0.0.3.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e15eb18d22433c743b901b0596e6933580512638d0466b380537d42e16ca291
|
|
BLAKE2b-256 checksum How to use checksums |
12f3ad48725628501d2f7815b2cf23b67b607f2e06946f7ad14c92654b687b29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.22
|
Release files / virtual_allocator-0.0.3-py3-none-any.whl
| Download URL | virtual_allocator-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ee5e68f842b100e5153de5a27d5a5bcd8445bf92afa77a0b012cf8075151661
|
|
BLAKE2b-256 checksum How to use checksums |
f900660c45a538b156e59b790829b66a7ee74e94081cd3c461120fb3045a4b16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.22
|
Security for virtual-allocator 0.0.3
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.