Concepts Common pitfalls
Confusing the abstraction with the implementation
A list is an abstract sequence; a Python list is a particular dynamic-array implementation. A map/dictionary is an abstract key-value lookup structure; a hash table is one implementation. This distinction matters because behaviour, ordering, memory use, and worst-case performance can differ.
Treating Big-O as a stopwatch
Big-O describes growth rate, not exact time. A theoretically “better” algorithm can be slower for small inputs if it has large constants, bad cache behaviour, extra allocations, GPU transfer overhead, or complicated control flow.
Forgetting side effects
A function can return the right value and still mutate global state, write a file, change a cache, consume a random number, or alter a device. When debugging, include side effects in the mental model:
input state -> function -> output statenot just:
input -> outputAssuming names prove meaning
Variables named sorted_data, probability, index, or gpu_time might be lies. Names are hints, not proofs. Trust invariants, tests, units, and direct inspection.
Ignoring ownership and lifetime
Many hard bugs come from using data after its owner has freed, moved, overwritten, or invalidated it. This appears in C/C++, GPU device buffers, file handles, sockets, database sessions, and temporary Python objects wrapped around external resources.