Optimizing tactics
- Choose the Right Data Structure (Dictionary?, Set?, List?)
- Sorting: Decorate Sort Undecorate (DSU) aka. Schwartzian Transform.
- String Concatenation: avoid extensive concatenation.
- Loops: for, list comprehension: use generators and iterators.
- Delay expanding range, map, filter, etc. iterables.
- Caching results, memoizing.
Read more performance tips