My question is around how the functions stored or executed in memory.
Coming from C++/Java here is my understanding (correct me if am wrong): class definitions and functions inside them are just instructions stored in the code section of the process/thread when the program is in memory. When a class is instantiated only member variables(non-static) will be having memory allocated separately in heap. i.e each object of class will have only instance variables and not function instructions. When a class function is executed via multiple objects it is executed through same location where the function is stored(i.e code section).
Now coming to python: Here functions are treated like objects. Which would mean functions are stored separately in heap and not in code section of the thread/process. And each object of the class will have its own copy of functions along with instance variables.
is my understanding correct? if it is correct what is use of having functions stored in every object?