EuroPython 2015

Import Deep Dive

Whatever you need to do with Python, you can probably import a library for it. But what exactly happens when you use that import statement? How does a source file that you’ve installed or written become a Python module object, providing functions or classes for you to play with?

While the import mechanism is relatively well-documented in the reference and dozens of PEPs, sometimes even Python veterans are caught by surprise. And some details are little-known: did you know you can import from zip archives? Write CPython modules in C, or even a dialect of Lisp? Or import from URLs (which might not be a good idea)?

This talk explains exactly what can happen when you use the import statement – from the mundane machinery of searching PYTHONPATH through subtle details of packages and import loops, to deep internals of custom importers and C extension loading.

in on Friday 24 July at 15:45 See schedule

Video


Do you have some questions on this talk?

New comment