Avatar for the pydantic user
pydantic
pydantic-core
BlogDocsChangelog

Don't try all union members when tagged discriminator match fails

#1902Closed
Comparing
navalprakhar:fix/tagged-union-serialization-fallback
(
0ab7684
) with
main
(
383eb95
)
CodSpeed Performance Gauge
0%
Untouched
163

Benchmarks

163 total
test_many_models_core_dict
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+6%
1,004.3 µs943.7 µs
test_list_of_ints_core_json
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+4%
761.7 µs734.3 µs
test_set_of_ints_core_json_duplicates
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+4%
434.3 µs419.3 µs
test_core_json_fs
tests/benchmarks/test_micro_benchmarks.py::TestModelLarge
CodSpeed Performance Gauge
+3%
175.2 µs170.3 µs
test_dict_of_ints_core_json
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+3%
1.4 ms1.4 ms
test_core_python
tests/benchmarks/test_micro_benchmarks.py::TestModelLarge
CodSpeed Performance Gauge
+3%
128.2 µs125 µs
test_smart_union_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion
CodSpeed Performance Gauge
+2%
15.7 µs15.4 µs
test_validate_literal[python-many_small_strings]
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
14.8 µs14.5 µs
test_core_python_fs
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkSimpleModel
CodSpeed Performance Gauge
+2%
70.6 µs69.3 µs
test_core_raw
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime
CodSpeed Performance Gauge
+1%
14.1 µs13.8 µs
test_date_from_datetime
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX
CodSpeed Performance Gauge
+1%
21.8 µs21.5 µs
test_core_model_py_extra
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+1%
28.4 µs28.1 µs
test_int_error
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
40 µs39.5 µs
test_core_python
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUUID
CodSpeed Performance Gauge
+1%
25.7 µs25.3 µs
test_validate_literal[python-few_str_enum]
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
14.9 µs14.8 µs
test_smart_union_coerce_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion
CodSpeed Performance Gauge
+1%
17.4 µs17.2 µs
test_date_format
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+1%
51.9 µs51.3 µs
test_arguments
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
24.3 µs24 µs
test_bool_core
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
22.4 µs22.2 µs
test_strict_union_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion
CodSpeed Performance Gauge
+1%
16.4 µs16.2 µs
test_validate_literal[python-few_large_strings]
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
14.8 µs14.6 µs
test_raise_error_custom
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
37.1 µs36.7 µs
test_chain_list
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
24.5 µs24.3 µs
test_isinstance_string_lax_false
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
15.6 µs15.4 µs
test_core_string_strict
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+1%
13.5 µs13.4 µs

Commits

Click on a commit to change the comparison range
Base
main
383eb95
+0.3%
Don't try all union members when tagged discriminator match fails
0ab7684
8 days ago
© 2026 CodSpeed Technology
Home Terms Privacy Docs