~/talk

The Craziest fn Thing I've Ever Seen (and It Lives in CPython!!!)

Talkat PyOhio 2021 · on Saturday, 2021-07-31· [python, compilers-and-language-design]
slides:none on file

Digs into CPython dataclasses and finds _create_fn, a generator that composes a name, args and body into source text and execs it into locals to synthesize real methods (used to build __init__, wrappers and the frozen-instance __setattr__/__delattr__ behavior). Demonstrates constructing add_two_numbers at runtime, seeing the function appear in locals and calling it successfully, and credits Eric V. Smith et al while highlighting practical metaprogramming and decorator machinery.

AI-written summary · about

  1. 0:00Intro
  2. 0:14What are Data Classes
  3. 1:01What are Data Classes in Kotlin
  4. 2:03The Problem
  5. 3:10The Function
  6. 3:53Adding Two Numbers
  7. 4:34Extra Fun
  8. 4:58Conclusion
~/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.