~/talk

Hacking the Python Import System

Talkat PyCon Israel 2024 · on Monday, 2024-09-16· [python, compilers-and-language-design]
name:Liad Oz
github:liadoz
slides:none on file

Explains how Python resolves imports by implementing sys.meta_path finders and loader objects with create_module and exec_module, and shows exactly which sys.path entries Python iterates. Demonstrates a working proxy loader that redirects imports of a Linux‑only package to a remote server via an RPC proxy, and a proof‑of‑concept that asks OpenAI to synthesize missing modules (OpenAI-generated modules). Demos run but the AI generator is inconsistent and unsafe for production; the loader approach reliably replaces platform‑restricted packages.

AI-written summary · about

  1. 0:00Introduction to Python imports
  2. 1:14How Python import system works
  3. 3:02Role of finder and loader objects
  4. 5:36Built-in finders in Python
  5. 8:08PYTHONPATH and sys.path
  6. 11:25Extending the import system
  7. 11:45Remote module proxy example
  8. 14:44AI-generated modules demo
  9. 16:38Live demo of AI import
  10. 19:44Important warnings and resources
~/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.