A simple timing decorator (wraps-preserving ergonomics)
Intermediate
Accelerating numerics & developer hygiene
Created by Pavel
· 29.04.2026 at 19:11 UTC
Decorators that add timing/logging should use functools.wraps so __name__, __doc__, and annotations remain intact for profilers and Sphinx. This card connects the V06 decorator lesson to performance measurement: wrap fn, record perf_counter deltas, optionally log, return the original result.
Production systems add structured logging, sampling, and async context—but the student pattern is the same: outer function, inner wrapper, preserve metadata.
functools.wraps: [1].
Sources
University approvals: 0
Tasks
Card Info
- Topic: Accelerating numerics & developer hygiene
- Difficulty: Intermediate
- Completed: 0 users
Creator
Pavel