Performance: Application factory pattern preview
MEDIUM IMPACT
This pattern affects the initial page load speed and memory usage by controlling when and how the Flask app and its components are created.
from flask import Flask def create_app(): app = Flask(__name__) @app.route('/') def home(): return 'Hello World!' return app if __name__ == '__main__': app = create_app() app.run()
from flask import Flask app = Flask(__name__) @app.route('/') def home(): return 'Hello World!' if __name__ == '__main__': app.run()
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| App created at import | N/A | N/A | Blocks server start | [X] Bad |
| App created via factory | N/A | N/A | Non-blocking startup | [OK] Good |