I noticed that member functions of built-in and user-defined classes have different types. Does that mean the two may behave differently in some situations?
class A:
def a():
pass
>>> type(A.a), type(list.append)
(<class 'function'>, <class 'method_descriptor'>)
They both perform their function normally, if that’s what you mean. They both are callable. Otherwise there are few differences between them.
One difference is that you can set arbitrary attributes on
functionobjects, but not on a C function (such aslist.append).Another is that a Python function has a code object associated with it, containing the compiled bytecode and information about local variables and such. The C function, naturally, lacks that information.