Jun-20-2020, 03:29 PM
Several things are wrong
- The print() statement is very slow and its execution time varies. Don't include it in the test.
- Here you want to compare the difference between
vars()['foo']
andmy['foo']
. Don't include anything else in the test
- Use the timeit module, which is much more precise because it runs the statements 1,000,000 times by default and uses a good timer.