numpy
2.0.0
|
#include <Python.h>
#include "structmember.h"
#include <numpy/ndarraytypes.h>
#include "numpy/arrayobject.h"
#include <numpy/npy_common.h>
#include "npy_config.h"
#include <assert.h>
#define _MULTIARRAYMODULE |
#define NBUCKETS 1024 |
#define NBUCKETS_DIM 16 |
#define NCACHE 7 |
#define NPY_NO_DEPRECATED_API NPY_API_VERSION |
#define PY_SSIZE_T_CLEAN |
static NPY_INLINE void* _npy_alloc_cache | ( | npy_uintp | nelem, |
npy_uintp | esz, | ||
npy_uint | msz, | ||
cache_bucket * | cache, | ||
void *(*)(size_t) | alloc | ||
) | [static] |
References cache_bucket::available, NCACHE, and cache_bucket::ptrs.
Referenced by _npy_free_cache().
static NPY_INLINE void _npy_free_cache | ( | void * | p, |
npy_uintp | nelem, | ||
npy_uint | msz, | ||
cache_bucket * | cache, | ||
void(*)(void *) | dealloc | ||
) | [static] |
References _npy_alloc_cache(), NBUCKETS, and PyDataMem_NEW().
Referenced by npy_free_cache().
NPY_NO_EXPORT void* npy_alloc_cache | ( | npy_uintp | sz | ) |
NPY_NO_EXPORT void* npy_alloc_cache_dim | ( | npy_uintp | sz | ) |
NPY_NO_EXPORT void* npy_alloc_cache_zero | ( | npy_uintp | sz | ) |
NPY_NO_EXPORT void npy_free_cache | ( | void * | p, |
npy_uintp | sz | ||
) |
References _npy_free_cache(), NBUCKETS_DIM, NPY_UNLIKELY, and PyArray_free.
NPY_NO_EXPORT void npy_free_cache_dim | ( | void * | p, |
npy_uintp | sz | ||
) |
NPY_NO_EXPORT void PyDataMem_FREE | ( | void * | ptr | ) |
NPY_NO_EXPORT void* PyDataMem_NEW | ( | size_t | size | ) |
NPY_NO_EXPORT void* PyDataMem_NEW_ZEROED | ( | size_t | size, |
size_t | elsize | ||
) |
NPY_NO_EXPORT void* PyDataMem_RENEW | ( | void * | ptr, |
size_t | size | ||
) |
NPY_NO_EXPORT PyDataMem_EventHookFunc* PyDataMem_SetEventHook | ( | PyDataMem_EventHookFunc * | newhook, |
void * | user_data, | ||
void ** | old_data | ||
) |
<blockquote>
void hook(void *old, void *new, size_t size, void *user_data).
</blockquote>
Returns a pointer to the previous hook or NULL. If old_data is non-NULL, the previous user_data pointer will be copied to it.
result = PyDataMem_NEW(size) -> (*hook)(NULL, result, size, user_data) PyDataMem_FREE(ptr) -> (*hook)(ptr, NULL, 0, user_data) result = PyDataMem_RENEW(ptr, size) -> (*hook)(ptr, result, size, user_data)
When the hook is called, the GIL will be held by the calling thread. The hook should be written to be reentrant, if it performs operations that might cause new allocation events (such as the creation/destruction numpy objects, or creating/destroying Python objects which might cause a gc)
cache_bucket datacache[NBUCKETS] [static] |
cache_bucket dimcache[NBUCKETS_DIM] [static] |