NumPy C code explanations
The interpretation of this memory depends on the stride information. For each dimension in an N -dimensional array, an integer ...
The interpretation of this memory depends on the stride information. For each dimension in an N -dimensional array, an integer ...
A number of functions, supplied by numpy.i, are called to make and check the (possible) conversion from a generic Python object to a NumPy array. These functions are explained in the section Helper Functions, but hopefully their names are self-explanatory.
This function must be declared so that it is visible to code outside of the routine. Besides adding the methods and constants you desire, this subroutine must also contain calls like import_array() and/or import_ufunc() depending on which C-API is needed.
All array creation functions go through this heavily re-used code. Because of its flexibility, it can be somewhat confusing to use.The function returns None and updates the output array. Note the updated use of WRITEBACKIFCOPY semantics for NumPy v1.14 and above.
import_array(); return PyModule_Create(&moduledef); } The mymethods must be an array (usually statically declared) of PyMethodDef structures which contain method names, actual C-functions, a variable indicating whether the method uses keyword arguments or not, and docstrings.