Chapter 1
- In the order of importance: functionality, correctness, and efficiency.
- An
assert
statement raises an error when the condition it checks for is not satisfied. As such, these statements are used in tests, where we determine whether a program computes and outputs values as it is supposed to. - A benchmark is a small but representative use case that can be used to estimate the speed of a program. Benchmarks can be used to compare different versions of a program to see if a new implementation leads to an improvement in efficiency.
- In IPython or Jupyter notebooks, the
timeit
magic command, when placed in front of a code snippet, will run that code several times and record the running time of each run. The output of the command will show summary statistics of the recorded times so that we can estimate the average running time of the code we are interested in. cProfile
includes the following in its output:ncalls
: The number of times the function was called.tottime...