MrlixiangWE opened a new pull request, #169:
URL: https://github.com/apache/otava/pull/169

   Constructing an `AnalyzedSeries` runs change point detection for every 
metric up front, even when the caller never reads the results. #79 asks for 
`change_points` and `change_points_by_time` to become properties instead.
   
   `change_points`, `weak_change_points`, `change_points_by_time` and 
`change_points_timestamp` are now read-only properties backed by private 
fields. The first access computes everything once and caches it; `append()` and 
`from_json()` write the backing fields directly. Two behavior notes:
   
   - `change_points_timestamp` now records when the change points were actually 
computed rather than when the object was constructed. A timestamp stored in 
JSON still takes precedence on deserialization.
   - Constructing with an explicit `change_points` argument used to leave 
`weak_change_points` unset, so reading it raised `AttributeError` unless 
`from_json` patched it afterwards. It now defaults to an empty collection.
   
   Construction cost measured on random data (Linux, Python 3.11):
   
   | series | construction before | construction after | first access after |
   |--|--|--|--|
   | 1 metric x 2000 points | 64 ms | < 0.01 ms | 63 ms |
   | 4 metrics x 5000 points | 575 ms | < 0.01 ms | 616 ms |
   
   Callers that do read change points pay the same total cost as before, and 
repeated accesses hit the cache. Detection results are unchanged: no expected 
value in the test suite needed to change. The only adjusted test is 
`test_validate`, which used to fake an uncomputed state by assigning 
`change_points = None` and now constructs with an explicitly empty collection.
   
   Verification:
   
   - `pytest tests perf` (non-container): 194 passed, including three new 
regression tests for laziness/caching, `append()` on a freshly constructed 
instance, and deserialization without recomputation
   - `flake8`, `ruff check`, `ruff format --check`, `isort --check-only`: clean
   - `git diff --check`: clean
   
   Closes #79


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to