MCPcopy Create free account
hub / github.com/numpy/numpy / npy_cache_import

Function npy_cache_import

numpy/core/src/common/npy_import.h:19–30  ·  view source on GitHub ↗

! \brief Fetch and cache Python function. * * Import a Python function and cache it for use. The function checks if * cache is NULL, and if not NULL imports the Python function specified by * \a module and \a function, increments its reference count, and stores * the result in \a cache. Usually \a cache will be a static variable and * should be initialized to NULL. On error \a cache will con

Source from the content-addressed store, hash-verified

17 * @param cache Storage location for imported function.
18 */
19static inline void
20npy_cache_import(const char *module, const char *attr, PyObject **cache)
21{
22 if (NPY_UNLIKELY(*cache == NULL)) {
23 PyObject *mod = PyImport_ImportModule(module);
24
25 if (mod != NULL) {
26 *cache = PyObject_GetAttrString(mod, attr);
27 Py_DECREF(mod);
28 }
29 }
30}
31
32#endif /* NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ */

Callers 15

array_descr_setFunction · 0.85
PyArray_GetFieldFunction · 0.85
PyArray_DumpFunction · 0.85
PyArray_DumpsFunction · 0.85
raise_memory_errorFunction · 0.85
void_common_instanceFunction · 0.85
PyArray_GetCastFuncFunction · 0.85
NpyPath_PathlikeToFspathFunction · 0.85
array_shares_memory_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected