The difference is based on how the methods work in python
note that
>>> Bb <unbound method B.<lambda>>
In fact, methods are created using
Updating the "method", the handle does not change
Inside the descriptor, we find that the main function performs
class B (object): def b(self): return 1 b = lambda self: 42 print id(getattr(B, 'b')) print id(b) setattr(B, 'b', b) print id(getattr(B, 'b')) print id(getattr(B, 'b').im_func)
You can also watch
B.__dict__['b']
before and after
source share