~/talk

Refactoring for fun and profit

Talkat PyCon AU 2023 · 2023-08-18..08-22· [developer-experience, testing, python]
slides:none on file

Refactors a messy Python side project that computes and annotates minimum paths for a train game into small classes and clear entry points, using Black for formatting, linters and an IDE for automated renames and extracts, and MonkeyType plus mypy for adding and checking types. Profiling with a Scalene profiler finds a hotspot in coordinate creation, fixed by moving work off init and using cached_property; tests and integration checks keep behavior stable and make collaboration possible.

AI-written summary · about

  1. 0:00Start
  2. 0:40Intro
  3. 3:30Formatting
  4. 4:19Pragmatism
  5. 5:03Linting
  6. 5:43Abstraction, Interface Segregation, & Dependency Inversion
  7. 8:42Is there a better way?
  8. 9:10Refactoring using IDEs
  9. 10:51Benefits of typing
  10. 11:58Adding types with MonkeyType
  11. 12:47Documentation through typing
  12. 14:47Documentation through structure
  13. 17:12Benefits of Python's amazing argument system
  14. 19:00Single Responsibility Principle
  15. 19:47DRY Principle
  16. 20:53Caveats of Utils
  17. 21:21Is there a better way?
  18. 21:42KISS Principle
  19. 23:09YAGNI Principle
  20. 23:40Benefits of testing
  21. 24:13Refactoring for testing after violating Dependency Inversion
  22. 25:24Profiling using Scalene
  23. 26:16Benefits of functools.cached_property
  24. 27:33Profit?
  25. 27:53Resources
  26. 28:08Outro
  27. 29:26Question: What would you do to ensure that you don't accidentally break things, when refactoring with no tests?
  28. 31:23Question: Is there a format for docstrings that are a good replacement for typing, since setting up typing is not always an option?
  29. 33:19Question: Do you prefer to omit types and instead use docstrings to provide context for complex nested types?
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.