Doing stupid things with ASTs
summary
Code-level details matter: Python's ast + Inspect + Python 3.9 unparse get real ASTs, and the drawing backend uses the stdlib turtle drawing to render outputs. Genetic-programming techniques — subtree crossover, mutation, pruning and tournament selection — produce new functions by compiling mangled ASTs back to code. The system sometimes generates recognisable flowers but also huge bloat and many nonfunctional programs; the core failure is the fitness metric — measuring “flower-ness” proves as hard as solving the problem, so evolution works but doesn't reliably solve the goal.
AI-written summary · about
chapters (6)
- 0:00Start
- 6:53A stupid idea
- 8:07Drawing flowers
- 14:54Multiple Generations
- 19:03Evolving Code Fitness functions
- 23:52Conclusions Don't do this
related talks
24mThe AST and Me
36mHacking the Python AST
22mDecoding: programming beyond text files
32mCode as Data_ A Practical Introduction to Python’s Abstract Syntax Tree
34mFinding and creating gambiarras with python ASTs
17mUnlocking Python's AST: The Metaprogramming Superpower You Didn't Know You Had
31mDon't Do This
31mSupercharge your Python library using AST parsing
