A function with one loop removes duplicates from a thousand items in 2.5 ms and from a hundred thousand in 27 seconds. In this chapter, we count steps instead of seconds to find out why: the growth rates from constant to factorial, the time and space complexity of every line, Big-O, Big Omega, and Big Theta with best, worst, and average cases, and amortized cost. We also turn a coding problem’s input size into a time budget.
A short story about what Pythonic might mean, an idea that involves a fair amount of interpretation and subjectivity.
In the age of AI, syntax by itself is the least important part of object-oriented programming to focus on. In this chapter, we cover classes, instance and class attributes, static and class methods, properties, encapsulation, inheritance, composition, and polymorphism against a problem from production code, a rate limiter for alerts. Along the way, we see what the SOLID principles warn about, what inheritance costs, and why composition is the more flexible approach.