25

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
  • 6,732
  • 5
  • 44
  • 50
mrKelley
  • 3,365
  • 2
  • 21
  • 28

1 Answers1

43
  • 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
  • 338,267
  • 99
  • 616
  • 750