-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
19 lines (14 loc) · 687 Bytes
/
Copy pathapi.py
File metadata and controls
19 lines (14 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""The pattern applied: a ``random``-style module API over shared state.
One hidden collector is built at import time (cheap: two empty dicts); its
bound methods become the module's public functions. Callers write
``metrics.increment("orders")`` — no instance in sight — while the instance
rides along inside each bound method.
"""
from __future__ import annotations
from patterns.python.prebound_method.examples.metrics.collector import MetricsCollector
_collector = MetricsCollector()
#: The pattern: module-level names bound to the hidden instance's methods.
increment = _collector.increment
timing = _collector.timing
snapshot = _collector.snapshot
reset = _collector.reset