PyCon Israel 2024

Your locale preferences have been saved. We like to think that we have excellent support for English in pretalx, but if you encounter issues or errors, please contact us!

Hacking the Python Import System
09-16, 13:30–13:50 (Asia/Jerusalem), Hall 1
Language: עברית

Delve into the inner workings of Python's import system. Learn how standard imports are implemented, and how to extend the import statement to provide new functionality.


The Python import system is more dynamic and extensible than most people realize. While most users primarily use it to import built-in and installed packages, there are additional options available, such as importing from zip packages and C modules. Moreover, Python allows you to hook into the import machinery to write your own import procedures.
In this talk, we will explore how the import system works behind the scenes. We will cover finders, loaders, and sys.meta_path. How the default file importer works, explaining sys.path, PYTHONPATH and how relative imports work. We will see how these are implemented in Python with code snippets.
We will see 2 example usages of import hooks, one practical, the other, extremely ridiculous.


Expected experience level of participants

Intermediate

Target audience

Developers

I'm a software developer who loves digging into how things work, even if it means breaking stuff in the process. I spend most of my time building tools and systems in Python and contributing to open-source projects.