-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Getting Started With The C side of Numpy
ǹp.array is written in C, and is part of the multiarray module that is defined here:
https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/multiarraymodule.c
The "array" name is mapped here:
to the function _array_fromobject defined here:
That functions does some checking and has a couple of fast paths for the case where the input is already an array or a subclass, but for the general case it relies on PyArray_CheckFromAny:
https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1848
which in turn calls Pyarray_FromAny:
https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1674
You will also haveto take a look at what goes on in PyArray_GetArrayParamsFromObject, which gets called by PyArray_FromAny;
https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L1428
as well as several other places, but I think they are all (or most of them) in ctors.c.
You may also want to take a llok at PyArray_FromIter, which is the function that ultimately takes care of calls to np.fromiter:
https://github.com/numpy/numpy/blob/maintenance/1.11.x/numpy/core/src/multiarray/ctors.c#L3657
Written by Jaime Fernández del Río as an answer to query on the mailing list