Skip to main content

Configurable memory allocations

Project description

Memory management in NumPy*

Binder PyPI version

*NumPy is a trademark owned by NumFOCUS.

Customize Memory Allocators

Α metaclass is used to override the internal data memory routines. The metaclass has four optional fields:

>>> import ctypes
>>> import ctypes.util
>>> import numpy_allocator
>>> my = ctypes.CDLL(ctypes.util.find_library('my'))
>>> class my_allocator(metaclass=numpy_allocator.type):
...     _calloc_ = ctypes.addressof(my.calloc_func)
...     _free_ = ctypes.addressof(my.free_func)
...     _malloc_ = ctypes.addressof(my.malloc_func)
...     _realloc_ = ctypes.addressof(my.realloc_func)
...

An example using the allocator

>>> import numpy as np
>>> with my_allocator:
...     a = np.array([1, 2, 3])
...
>>> my_allocator.handles(a)
True

Project details


Download files

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

Source Distribution

numpy-allocator-1.2.0.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distributions

numpy_allocator-1.2.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_allocator-1.2.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (15.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_allocator-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl (41.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

numpy_allocator-1.2.0-cp311-cp311-musllinux_1_1_i686.whl (39.3 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

numpy_allocator-1.2.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (35.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_allocator-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl (40.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

numpy_allocator-1.2.0-cp310-cp310-musllinux_1_1_i686.whl (38.3 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

numpy_allocator-1.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (34.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_allocator-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl (39.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

numpy_allocator-1.2.0-cp39-cp39-musllinux_1_1_i686.whl (37.7 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

numpy_allocator-1.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (34.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

numpy_allocator-1.2.0-cp38-cp38-musllinux_1_1_x86_64.whl (41.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

numpy_allocator-1.2.0-cp38-cp38-musllinux_1_1_i686.whl (39.5 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

numpy_allocator-1.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (37.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_allocator-1.2.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (35.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page