23

I built it myself on Python 3.3, but I can't for the life of me find the class definition of numpy.array(). I've looked all through the code and even found the core C files, but where is the dang array class??

Can anyone tell me what directory to look in, or how to find out from the python shell?

Tarod
  • 5,804
  • 5
  • 38
  • 45
mrKelley
  • 2,925
  • 1
  • 17
  • 28

1 Answers1

37
  • np.array is not a class itself, just a convenience function to create an np.ndarray
  • ndarray is just aliased to multiarray, which is implemented in C code (I think in an .so i.e. shared object, compiled code)
  • You can start looking at the ndarray interfaces here in numeric.py.
  • Most of the meat of the implementation is in C code, here in multiarray.
  • array() is implemented in core/src/multiarray/methods.c in array_getarray()
wim
  • 266,989
  • 79
  • 484
  • 630