Iterators and generators
An iterator is any object with iter and next that raises StopIteration when done; a generator function (one with yield) builds one for you. In LLD rounds use them to make custom collections (parking floors, playlists) iterable and to stream data lazily instead of building big lists.
Decorators
A decorator is a callable that takes a function (or class) and returns a replacement, applied with @name. In LLD rounds they keep cross-cutting concerns (timing, retry, logging, auth checks, caching) out of business logic. Always use functools.wraps so the wrapped function keeps its name and docstring.
Context managers
A context manager pairs setup with guaranteed teardown via with: enter runs on entry, exit always runs on exit (even on exceptions). In LLD rounds use them for locks, DB transactions, file/connection handles and "acquire then release" resources like a parking spot or a rate-limit token.
Threading primitives
threading gives you OS threads plus sync primitives guard shared state (counters, spot maps, booking seats) with a lock and use Condition/Queue for blocking hand-offs.
concurrent.futures
High-level thread and process pools: submit callables, get back Futures, collect results. Use ThreadPoolExecutor for I/O-bound fan-out (sending notifications, calling payment/inventory services) and ProcessPoolExecutor for CPU-bound work. Far less code than managing Threads and queues yourself.
datetime and time
datetime handles calendar dates/times and durations; time gives raw clocks. In LLD rounds you need them for booking/reservation windows, parking fees, expiry/TTL, and rate limiters. Rule of thumb: store timezone-aware UTC datetimes, and measure elapsed time with time.monotonic().
uuid and id generation
Every LLD entity (user, ticket, booking, order) needs an id. Use uuid.uuid4() for random, globally unique ids; uuid.uuid7() (3.14+) when you want ids that sort by creation time; and itertools.count for simple readable sequential ids.
bisect
2 items
itertools
6 items