Fun with Python's newer tools
summary
Shows concrete new tools and exact code behaviors: use collections.Counter.most_common(50) to get top 50 words (Hamlet example) and combine counters with addition while noting subtraction can produce negatives unless you use saturating logic; use collections.namedtuple plus a ._replace prototype pattern for readable defaults and zero memory overhead; use functools.lru_cache(maxsize=100) to bound caches (fib(100) reduces calls to ~101); new str.format features include thousand separators and attribute/index access.
AI-written summary · about
chapters (15)
- 0:00Intro
- 7:57Counter
- 17:03Tuples
- 21:41Test results
- 25:42API design
- 29:52Deal structure
- 30:57Default values
- 32:44Uniques
- 34:35Color Palette
- 36:32Cash
- 41:02Dynamic Programming
- 44:06Torsion
- 44:48Count
- 46:14String Formatting
- 53:48Subtract
related talks
19mPython - best practices
29mI wish I learnt that earlier!
25mLet's implement useless Python objects
46mBest Practices for Python Scripting
25mThe Standard Library Tour
20mLesser known data structures
43mPython Improvements (or This Is Not Your Teacher's Python)
33mElegant Solutions For Everyday Python Problems
