Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why numpy.array is built-in?

Tags:

python

numpy

According to https://docs.python.org/3/library/functions.html, the "built-in function" means a python-innate function such as print or sum.

However, type(numpy.array) results in builtin_function_or_method even though the numpy module is not python-innate.

Why does it happen?

like image 203
Kang San Lee Avatar asked Oct 24 '25 17:10

Kang San Lee


1 Answers

Because builtin_function_or_method is not really testing if it is a built in (which is rather a bit ambiguous term). Rather, it tests if a function or method was written in C.

From the official document:

types.BuiltinFunctionType

types.BuiltinMethodType

The type of built-in functions like len() or sys.exit(), and methods of built-in classes. (Here, the term “built-in” means “written in C”.)

like image 186
Chris Avatar answered Oct 27 '25 05:10

Chris