~/talk

Dynamically generated methods with a non-generic signature

Talkat PyCon Italia 2024 · 2024-05-22..05-25· [python]
slides:none on file

Generates per-subclass setter methods for scikit-learn Estimators by inspecting child method signatures (so a custom set_transform_request appears only if transform defines extra params), attaches callable via a descriptor at subclass creation, and writes a matching PEP-362 Signature and docstring so help() and IDE introspection show precise params. Uses inspect to read signatures, descriptors to return functions, and __init_subclass__ (PEP-487) to attach them; approach is deployed in scikit-learn and works at import time.

AI-written summary · about

  1. 0:00Introduction and motivation
  2. 3:43Understanding inspect module
  3. 6:33Functions returning functions
  4. 10:10Python signature object
  5. 10:30Descriptors in Python
  6. 14:07Descriptor returning a function
  7. 17:21Init subclass explained
  8. 20:35Putting it all together
  9. 23:57Maintainability and black magic
  10. 27:10Documentation and IDE support
  11. 28:13Language servers and type checkers
  12. 30:00Q&A and closing
~/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.