There is an obvious difference that you cannot put print statements in anonymous function a.k.a lambda function
Anyway, all things being equal, I immediately felt that was really a good question for the reason that whether two produce same byte code for the same program.
Here we will find out.
In : def add(x,y): ...: return x+y ...: In : k = lambda x,y : x+y In : import dis In : dis.dis(add) 2 0 LOAD_FAST 0 (x) 3 LOAD_FAST 1 (y) 6 BINARY_ADD 7 RETURN_VALUE In : dis.dis(k) 1 0 LOAD_FAST 0 (x) 3 LOAD_FAST 1 (y) 6 BINARY_ADD 7 RETURN_VALUE In :
As you can see both generated byte codes, there is no difference between the two.