By Alyssa Coghlan

from where?!? import what?!?

Main Conference Ballroom 3 Saturday at 10:45am - 11:15am

import re. from pathlib import Path. Python's import system is easy to take for granted, and most of the time we don't need to think about how the import statements we write actually work. Sometimes, however, things do go wrong, and knowing where to look for more information can mean the difference between scratching our heads in bafflement and quickly solving whatever problem we're facing.

For a lot of import related problems, the exception and associated traceback tell us everything we need to know to resolve the issue. Other problems can require a deeper investigation. Are we actually importing the module we think we’re importing? Is the interpreter even looking in the right place for the modules we expect it to be loading? We’ve noticed our application is taking ages to start, where is all that time going?

Even without any third party components, the CPython core interpreter and standard library offer a range of utilities to learn more about how the import system has been configured, and exactly what it is doing at runtime. This talk will cover several of these tips and tricks for investigating import system misbehaviour from one of the people that wrote it.

Alyssa Coghlan

Alyssa Coghlan

Alyssa has been a CPython core contributor since 2005, and served on the inaugural Python Steering Council in 2019. She contributed the first implementation of the -m switch in Python 2.4 and has been the lead maintainer of the associated runpy module ever since its introduction as part of PEP 338 in Python 2.5. She doesn’t actually know how many import system related CPython modifications she has contributed or reviewed, and has no intention of going back and attempting to count them.