From 7aa603d788e23c7bb6a4cc8441cb5b37ea63ab14 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Fri, 25 Nov 2011 18:50:25 -0800 Subject: [PATCH] Wrap make_app to allow r2 imports before pyx build. --- r2/r2/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)