Most of the things we have learned about dynamic and static typing can be applied to functions as well. So, let’s understand some basic things about functions in Python and C.
Functions in both of these languages have some common attributes, like both (usually) have a name, take zero or more arguments, and can return new values or objects when called.
But python's functions are very flexible and powerful. They are first-class citizens.
A general Python function can be: Created both at import time and dynamically at runtime. It can be created anonymously Using LAMBDA Keyword. It can be defined inside the other function (Like a nested function). It can also return from another function. We can pass it as an argument to other functions. It can take positional or keyword arguments. And, also we can define python functions with default values.
Now, let’s talk about a general C function: We can pass it as an argument to other functions. But it cannot be defined inside functions. They have a statically assigned name that is not modifiable. C functions can take positional arguments only. And, It does not support default values for parameters.
But keep in mind that, all of the power and flexibility of Python functions comes at a cost: Python functions are several orders of magnitude slower than C functions even functions that take no arguments.
Fortunately, Cython supports both Python and C functions and allows them to call each other in a natural and straightforward way, all in the same source file.