~/talk

Finding and creating gambiarras with python ASTs

Talkat GambiConf EU 2022 · 2022-09-03..09-10· [python, machine-learning]
slides:none on file

PyASTrX finds messy code by converting Python ASTs to XML and letting XPath match patterns, so it detects issues like mutable defaults and recursion-in-class definitions and highlights exact locations. It demonstrates a metaprogramming workflow using ast.NodeTransformer to replace validate_data calls in sklearn pipelines, avoiding repeated validation during grid search and saving CPU. The tool also supports writing compact XPath rules and transforming AST back to source for automated fixes.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 1:06What is a gambiarra
  3. 2:34Language limits in code
  4. 4:46Meta programming basics
  5. 7:20Russian literature and code
  6. 10:13Code style guide flaws
  7. 13:30Bias Tweaks philosophy
  8. 15:17Part one overview
  9. 16:19Python compilation process
  10. 17:21Abstract syntax trees explained
  11. 20:54Fixing code with ASTs
  12. 23:49Transformer limitations
  13. 25:14Should Python be serious
  14. 25:59Part two overview
  15. 26:42Finding patterns with XPath
  16. 29:46AST to XML conversion
  17. 31:51Normalizing ASTs
  18. 32:36Future of code analysis
  19. 33:18Closing remarks
~/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.