Performance: Flask session object
MEDIUM IMPACT
This affects page load speed and responsiveness by how session data is stored and retrieved during requests.
from flask import session # Store only small, essential data like user ID session['user_id'] = user.id # Batch session updates to a single write session.update({'step1': value1, 'step2': value2, 'step3': value3})
from flask import session # Storing large data directly in session session['user_data'] = large_complex_object # Modifying session data multiple times per request session['step1'] = value1 session['step2'] = value2 session['step3'] = value3
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large session data stored in cookies | N/A | N/A | Increases browser parsing time | [X] Bad |
| Minimal session data with batched updates | N/A | N/A | Minimal impact on parsing and rendering | [OK] Good |