diff --git a/r2/r2/__init__.py b/r2/r2/__init__.py index fa85019b7..0bc6cb0cb 100644 --- a/r2/r2/__init__.py +++ b/r2/r2/__init__.py @@ -23,4 +23,11 @@ This file loads the finished app from r2.config.middleware. """ -from r2.config.middleware import make_app + +# defer the (hefty) import until it's actually needed. this allows +# modules below r2 to be imported before cython files are built, also +# provides a hefty speed boost to said imports when they don't need +# the app initialization. +def make_app(*args, **kwargs): + from r2.config.middleware import make_app as real_make_app + return real_make_app(*args, **kwargs)