! \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
| 17 | * @param cache Storage location for imported function. |
| 18 | */ |
| 19 | static inline void |
| 20 | npy_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_ */ |
no outgoing calls
no test coverage detected