Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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