python-attrs
attrs
BlogDocsChangelog

Replace cached_property on slotted classes with a new descriptor instead of writing `__getattr__`

#1488
Comparing
DavidCEllis:descriptor-cached-property
(
67a1858
) with
main
(
460f019
)
CodSpeed Performance Gauge
-72%
Improvements
1
Regressions
1
Untouched
13

Benchmarks

Failed

test_repeated_access
bench/test_benchmarks.py::TestCachedProperties
Regression
CodSpeed Performance Gauge
-72%
254.5 µs908.2 µs

Improved

test_create_cached_property_class
bench/test_benchmarks.py::TestCachedProperties
CodSpeed Performance Gauge
+54%
1.8 s1.1 s

Passed

test_astuple_complicated
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
8.7 ms8.7 ms
test_eq_equal
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
883.9 µs883.7 µs
test_astuple_atomic
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
5.6 ms5.6 ms
test_instantiate_with_defaults
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1.2 ms1.2 ms
test_hash
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1.1 ms1.1 ms
test_instantiate_no_defaults
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1.2 ms1.2 ms
test_eq_unequal
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
676 µs676.1 µs
test_create_simple_class_make_class
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1 s1 s
test_create_frozen_class
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1.3 s1.3 s
test_create_simple_class
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
1.1 s1.1 s
test_asdict_atomic
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
6.3 ms6.3 ms
test_asdict_complicated
bench/test_benchmarks.py
CodSpeed Performance Gauge
0%
9.4 ms9.4 ms
test_first_access
bench/test_benchmarks.py::TestCachedProperties
CodSpeed Performance Gauge
-2%
6.4 ms6.5 ms

Commits

Click on a commit to change the comparison range
Base
main
460f019
-0.04%
discrepancy
ea11e00
22 days ago
by DavidCEllis
-76.16%
Merge branch 'main' into descriptor-cached-property
f0a7887
20 days ago
by hynek
+4.22%
Try caching the get, set and delete methods for the slot.
921174e
20 days ago
by DavidCEllis
-0.01%
Add a benchmark for constructing classes with cached properties
65b5b35
20 days ago
by DavidCEllis
+0.01%
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
5e19f82
20 days ago
by pre-commit-ci[bot]
-0.01%
Merge branch 'main' into descriptor-cached-property
cc06080
14 days ago
by hynek
+0.02%
Merge branch 'main' into descriptor-cached-property
67a1858
11 days ago
by hynek
© 2025 CodSpeed Technology
Home Terms Privacy Docs