Default values are evaluated once, when the def statement runs, and stored on the function object — so both calls append to the same list and f(2) returns [1, 2]. A fresh list per call is the common wrong mental model; the fix is acc=None plus acc = [] in the body. Threads play no part, and Python accepts mutable defaults without complaint.
Official docs