Show Navigation
Conversation
Notices
-
Instagram's concept of strict Python modules and strict functions allows modules to be reloaded in a safe way and reduces startup times in a complex codebase, in addition to just the enhanced ability to understand the code because you know there is nothing fishy going on when you're simply importing a module.
farside.link/scribe/python-at-β¦
@python group #python #StrictModules #StrictPythonModules #PythonStrictModules
-
> But then someone else comes along, adds an innocuous import in some other part of the codebase, and through an import chain twelve modules deep, it causes the config-fetching module to now be imported before the one that does the initialization. Now weβre trying to use the service before itβs initialized, so it blows up.
Yeah, we have this, in not-very-complex applications, but which involve flask-sqlalchemy. The import order is very sensitive, so the app.py needs to be excused from flake8-import-order, and some other modules import app.py just so that it can get the import order right for them before they import the modules they actually need.