stdlib

Guides to the Python standard library and its most useful built-in modules.

Python Time Complexity: Lists, Dicts, Sets Under the Hood

Python time complexity is the reason two programs that produce identical results can finish in five milliseconds or twenty-seven seconds, and the difference usually comes down to which container you reached for. This post takes the four workhorse structures, list, dict, set, and tuple, and shows you exactly what each operation costs by running real timeit measurements, so you stop guessing and start picking the right tool on purpose. “The best programs are written so that computing machines can perform ... Read More

Sorting and Searching Algorithms in Python (From Scratch)

Ask a room of developers who last shipped a hand-written sort and you get silence; ask who was grilled on one in an interview and every hand goes up. Sorting algorithms are the push-ups of programming: rarely performed on the job, but they build the muscle the job needs. Here you write linear and binary search plus four classic sorts, then time them against Python’s own sorted(). “Let me see your code and I won’t usually need your flowcharts; show ... Read More

Stacks and Queues in Python, Explained With deque

Stacks and queues are the two simplest ways to line up data, and once you can see them you start noticing them everywhere: the browser back button, the undo key, the print jobs waiting on a shared printer. This post builds both from Python’s standard library, wires up a linked list by hand so you understand what a “pointer” really is, and then puts them to work on the exact problems interviewers love to ask. “Bad programmers worry about the ... Read More