Reputation: 382
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?
Upvotes: 4
Views: 260
Reputation: 29742
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.
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”.)
Upvotes: 5