Performance: Email verification pattern
MEDIUM IMPACT
This pattern affects page load speed and interaction responsiveness during user registration and verification steps.
from flask import Flask, request, jsonify from threading import Thread app = Flask(__name__) def send_verification_email_async(email): # simulate sending email import time time.sleep(5) print(f'Verification email sent to {email}') @app.route('/register', methods=['POST']) def register(): email = request.form['email'] Thread(target=send_verification_email_async, args=(email,)).start() return jsonify({'message': 'Registration complete, verification email sent asynchronously'})
from flask import Flask, request import time app = Flask(__name__) @app.route('/register', methods=['POST']) def register(): email = request.form['email'] # Simulate sending email synchronously send_verification_email(email) # blocks request until done return 'Registration complete, check your email!' def send_verification_email(email): time.sleep(5) # simulate delay print(f'Verification email sent to {email}')
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous email sending | Minimal | N/A | Blocks paint until response | [X] Bad |
| Asynchronous email sending | Minimal | N/A | Immediate paint and interaction | [OK] Good |