On Sat, Dec 31, 2011 at 4:41 AM, Lie Ryan <lie.1...@gmail.com> wrote: > On 12/31/2011 08:48 AM, Ian Kelly wrote: >> >> >> But they are two distinct function objects, and there is no way >> programmatically to determine that they are the same function except >> by comparing the bytecode (which won't work generally because of the >> halting problem). > > > Actually, it is often possible to determine that two functions are the same > function, you simply need a to compare whether the function object lives in > the same memory address. It is also possible to determine if two functions > are different, if the function object are in different memory address than > the function is different function. > > What is difficult to do due to the Halting problem is comparing whether two > different functions are "equivalent" (and therefore interchangeable).
Yes, that is what I said. You can determine whether two function objects are the same, but not whether they are *mathematically* the same function. > I think the OP wants to find the former, not the latter. The former is > trivial, the latter impossible. Based on his subsequent clarification, I agree, although from his original post it sounded like he was just trying to identify summing functions in general. However, finding the built-in sum function on the stack is not trivial at all, perhaps not even possible. -- http://mail.python.org/mailman/listinfo/python-list