structuredClone handles Dates, Maps, Sets and cycles, which JSON round-tripping quietly destroys.
All Snippets
A collection of code, notes, and solutions.
Intl handles the symbol, the separators and the decimal places for the locale, so you never hand-roll them.
Turns a timestamp into 'three days ago' using the built-in formatter.
The modern API needs a secure context and a real user gesture, so the failure path matters as much as the success one.
Backs off on each failure and spreads retries out, so a recovering service is not hit by every client at once.
Iterating a file object yields one line at a time, which is the difference between a constant footprint and an OOM.
itertools.batched on 3.12 and later; the islice version works everywhere and never materialises the whole input.
__post_init__ runs after the generated constructor, which is where cheap invariants belong.
A context manager that prints how long its body took, without scattering time.perf_counter calls through the function.
argparse covers subcommands, types and help text, which is more than most scripts ever need.
The | operator returns a new dict; |= updates in place. Later keys win in both.
pathlib keeps the paths as objects rather than strings, so joining and suffix checks stay readable.