Talk Proposal: Getting the Most Out of Python Imports

30 August 2011 (Revised to current form 16 October)

https://us.pycon.org/2012/proposal/17/

status:Accepted
orphan:

Summary

To really take advantage of Python you must understand how imports work and how to use them effectively. In this talk we’ll discuss both of these. After a short introduction to imports, we’ll dive right in and show how you can put PEP 302 import hooks to work for you.

Abstract

Python’s import statement has been a powerful feature since the first release, and only gotten better with age. Understanding how imports work under the hood will let you take advantage of that power.

The key to customizing Python’s imports is the importers introduced by PEP 302. That’s a tool that you want in your belt!

Talk Outline

  1. Python’s imports (5 min) - the evolution of the import machinery - the gears in the machine - motivation for PEP 302
  2. Finder Objects (5 min) - what they’re for - how to write one - what to do with it
  3. Loader Objects (5 min) - what they’re for - how to write one - what to do with it
  4. sys.meta_path vs. sys.path_hooks (5 min) - when and how to use them - example of putting it all together
  5. Real-life Examples of Import Hooks (7 min) - Python/import.c - importlib module - PyPy - PyFilesystem
  6. Other Import Customizations (3 min) - builtins.__import__ - .pth files - PEP 402 - import engine

Much more information on Python imports may be found at my Python Imports page.

The Original Proposals

PyCon 2012 Talk: Getting the Most Out of Python Imports

  1. high-level overview of imports/modules in Python
  2. history of imports in Python
  3. introduction to PEP 302 import hooks
  4. import hook examples
  5. review of supplemental information
  6. questions

PyCon 2012 Talk: A History of the Python Import Statement

  1. high-level overview of imports/modules in Python
  2. brief history of Python
  3. influences on the initial import statement
  4. early additions
  5. the intervening years
  6. recent additions
  7. on-going efforts
  8. questions