File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -119,3 +119,56 @@ def test_hash():
119
119
120
120
for _ in range (ROUNDS ):
121
121
hash (c )
122
+
123
+
124
+ def test_asdict_complicated ():
125
+ """
126
+ Benchmark instances with non-shortcut fields.
127
+ """
128
+ c = C ()
129
+ ad = attrs .asdict
130
+
131
+ for _ in range (ROUNDS ):
132
+ ad (c )
133
+
134
+
135
+ def test_astuple_complicated ():
136
+ """
137
+ Benchmark instances with non-shortcut fields.
138
+ """
139
+ c = C ()
140
+ at = attrs .astuple
141
+
142
+ for _ in range (ROUNDS ):
143
+ at (c )
144
+
145
+
146
+ @attrs .define
147
+ class AtomicFields :
148
+ a : int = 0
149
+ b : Ellipsis = ...
150
+ c : str = "foo"
151
+ d : tuple [str ] = "bar"
152
+ e : complex = complex ()
153
+
154
+
155
+ def test_asdict_atomic ():
156
+ """
157
+ Benchmark atomic-only instances.
158
+ """
159
+ c = AtomicFields ()
160
+ ad = attrs .asdict
161
+
162
+ for _ in range (ROUNDS ):
163
+ ad (c )
164
+
165
+
166
+ def test_astuple_atomic ():
167
+ """
168
+ Benchmark atomic-only instances.
169
+ """
170
+ c = AtomicFields ()
171
+ at = attrs .astuple
172
+
173
+ for _ in range (ROUNDS ):
174
+ at (c )
You can’t perform that action at this time.
0 commit comments