I have the following code which defines a class and two class objects:
class A():
def instance_method(self):
pass
a1 = A()
a2 = A()
a1
and a2
does not appear to share the same instance method, which makes sense to me.
assert a1.instance_method is not a2.instance_method
However, when I checked the ID of the two methods, they appear identical.
assert id(a1.instance_method) == id(a2.instance_method)
So I am a bit confused about whether or not instances share an instance method. Can anyone shed a light on what's going on here in memory?