On 22/02/2018 12:03, bartc wrote:

On the fib(20) test, it suggests using this to get a 30,000 times speed-up:

BTW while doing my tests, I found you could redefine the same function with no error:

def fred():
        pass

def fred():
        pass

def fred():
        pass

For classes too. I was aware you could reassign a different value to such names, but didn't know this applied to def.

I guess the reason is that 'def' is just another statement, and statements can be conditional, so that you can have several versions.

It was still a surprise. What an easy way for things to go wrong by writing a new version of a function but forgetting to delete the original. And if they happen to be in the right order so the program still works, it must be confusing to read.

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to