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?

4

1 回答 1

41
  • np.array不是一个类本身,只是一个方便的函数来创建一个np.ndarray
  • ndarray只是别名为 multiarray,它是在 C 代码中实现的(我认为在 .so 中,即共享对象,编译代码)
  • 您可以在 numeric.py 中开始查看 ndarray接口
  • 实现的大部分内容都在 C 代码中,这里在 multiarray 中
  • array()core/src/multiarray/methods.c中实现array_getarray()
于 2013-05-22T03:31:13.290 回答