Skip to content

Commit 0a08cee

Browse files
hynekJohnny-Kao
andcommitted
Add benchmark for nested atomic fields
Co-authored-by: Johnny Kao <19386515+Johnny-Kao@users.noreply.github.com>
1 parent 644b4e1 commit 0a08cee

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎bench/test_benchmarks.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,22 @@ def test_astuple_atomic():
177177
at(c)
178178

179179

180+
@attrs.define
181+
class NestedAtomicFields:
182+
sequence: list[int] = attrs.Factory(lambda: list(range(100)))
183+
184+
185+
def test_astuple_nested_atomic():
186+
"""
187+
Benchmark atomic values nested in a sequence.
188+
"""
189+
c = NestedAtomicFields()
190+
at = attrs.astuple
191+
192+
for _ in range(ROUNDS):
193+
at(c)
194+
195+
180196
class TestCachedProperties:
181197
@attrs.define
182198
class Slotted:

0 commit comments

Comments
 (0)