Avatar for the pydantic user
pydantic
pydantic-core
BlogDocsChangelog

support `__pydantic_extra__` when serializing

#576Merged
Comparing
serialize-__pydantic_extra__
(
0fa626f
) with
main
(
d3f97e7
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
112
New
2
Dropped
0
Ignored
0

Benchmarks

New

test_core_model_json_extra
tests/benchmarks/test_serialization_micro.py::test_core_model_json_extra
CodSpeed Performance Gauge
N/A
N/A
55.7 µs
test_core_model_py_extra
tests/benchmarks/test_serialization_micro.py::test_core_model_py_extra
CodSpeed Performance Gauge
N/A
N/A
58.3 µs

Passed

test_core_json_fs
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkSimpleModel::test_core_json_fs
CodSpeed Performance Gauge
+7%
230.8 µs
215.4 µs
test_date_format_function_no_info
tests/benchmarks/test_serialization_micro.py::test_date_format_function_no_info
CodSpeed Performance Gauge
+3%
50.5 µs
48.8 µs
test_date_format_function
tests/benchmarks/test_serialization_micro.py::test_date_format_function
CodSpeed Performance Gauge
+2%
51.8 µs
50.5 µs
test_date_format
tests/benchmarks/test_serialization_micro.py::test_date_format
CodSpeed Performance Gauge
+2%
50.3 µs
49.1 µs
test_list_of_dict_models_core
tests/benchmarks/test_micro_benchmarks.py::test_list_of_dict_models_core
CodSpeed Performance Gauge
+1%
130.2 µs
128.5 µs
test_many_models_core_dict
tests/benchmarks/test_micro_benchmarks.py::test_many_models_core_dict
CodSpeed Performance Gauge
+1%
1.2 ms
1.2 ms
test_definition_model_core
tests/benchmarks/test_micro_benchmarks.py::test_definition_model_core
CodSpeed Performance Gauge
+1%
506.9 µs
500.5 µs
test_many_models_core_model
tests/benchmarks/test_micro_benchmarks.py::test_many_models_core_model
CodSpeed Performance Gauge
+1%
2.8 ms
2.8 ms
test_isinstance_string_strict_false
tests/benchmarks/test_micro_benchmarks.py::test_isinstance_string_strict_false
CodSpeed Performance Gauge
+1%
12.6 µs
12.5 µs
test_isinstance_string_lax_false
tests/benchmarks/test_micro_benchmarks.py::test_isinstance_string_lax_false
CodSpeed Performance Gauge
+1%
12.8 µs
12.7 µs
test_dict_of_ints_core
tests/benchmarks/test_micro_benchmarks.py::test_dict_of_ints_core
CodSpeed Performance Gauge
+1%
2.4 ms
2.4 ms
test_list_of_nullable_core
tests/benchmarks/test_micro_benchmarks.py::test_list_of_nullable_core
CodSpeed Performance Gauge
+1%
213.9 µs
212.4 µs
test_complete_core_json
tests/benchmarks/test_complete_benchmark.py::test_complete_core_json
CodSpeed Performance Gauge
+1%
713.5 µs
709.4 µs
test_python_json_list_str
tests/benchmarks/test_serialization_micro.py::test_python_json_list_str
CodSpeed Performance Gauge
+1%
167.3 µs
166.3 µs
test_core_dict
tests/benchmarks/test_serialization_micro.py::TestBenchmarkSimpleModel::test_core_dict
CodSpeed Performance Gauge
0%
81.9 µs
81.5 µs
test_build_schema
tests/benchmarks/test_complete_benchmark.py::test_build_schema
CodSpeed Performance Gauge
0%
1 ms
1 ms
test_definition_out_of_tree
tests/benchmarks/test_micro_benchmarks.py::test_definition_out_of_tree
CodSpeed Performance Gauge
0%
5.9 ms
5.9 ms
test_core_dict_filter
tests/benchmarks/test_serialization_micro.py::TestBenchmarkSimpleModel::test_core_dict_filter
CodSpeed Performance Gauge
0%
86.8 µs
86.5 µs
test_complete_core_isinstance
tests/benchmarks/test_complete_benchmark.py::test_complete_core_isinstance
CodSpeed Performance Gauge
0%
1.9 ms
1.8 ms
test_python_json_list_none
tests/benchmarks/test_serialization_micro.py::test_python_json_list_none
CodSpeed Performance Gauge
0%
135.8 µs
135.4 µs
test_list_of_ints_core_json
tests/benchmarks/test_micro_benchmarks.py::test_list_of_ints_core_json
CodSpeed Performance Gauge
0%
1.1 ms
1.1 ms
test_core_model_py
tests/benchmarks/test_serialization_micro.py::test_core_model_py
CodSpeed Performance Gauge
0%
27.2 µs
27.1 µs
test_dict_of_ints_core_json
tests/benchmarks/test_micro_benchmarks.py::test_dict_of_ints_core_json
CodSpeed Performance Gauge
0%
2.7 ms
2.7 ms
test_core_raw
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_core_raw
CodSpeed Performance Gauge
0%
11.8 µs
11.8 µs
test_python_json_list_int
tests/benchmarks/test_serialization_micro.py::test_python_json_list_int
CodSpeed Performance Gauge
0%
162.1 µs
161.8 µs
test_complete_core_error
tests/benchmarks/test_complete_benchmark.py::test_complete_core_error
CodSpeed Performance Gauge
0%
1.9 ms
1.9 ms
test_set_of_ints_core
tests/benchmarks/test_micro_benchmarks.py::test_set_of_ints_core
CodSpeed Performance Gauge
0%
1.9 ms
1.9 ms
test_model_exclude_unset_false
tests/benchmarks/test_serialization_micro.py::test_model_exclude_unset_false
CodSpeed Performance Gauge
0%
29.8 µs
29.8 µs
test_set_of_ints_core_json
tests/benchmarks/test_micro_benchmarks.py::test_set_of_ints_core_json
CodSpeed Performance Gauge
0%
1.3 ms
1.3 ms
test_frozenset_of_ints_core
tests/benchmarks/test_micro_benchmarks.py::test_frozenset_of_ints_core
CodSpeed Performance Gauge
0%
407.1 µs
407 µs
test_strict_union_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion::test_strict_union_core
CodSpeed Performance Gauge
0%
16.3 µs
16.3 µs
test_core_string_strict
tests/benchmarks/test_micro_benchmarks.py::test_core_string_strict
CodSpeed Performance Gauge
0%
11.7 µs
11.7 µs
test_validate_literal[python-few_small_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-few_small_strings]
CodSpeed Performance Gauge
0%
12.1 µs
12.1 µs
test_list_of_ints_core_py
tests/benchmarks/test_micro_benchmarks.py::test_list_of_ints_core_py
CodSpeed Performance Gauge
0%
1.6 ms
1.6 ms
test_definition_in_tree
tests/benchmarks/test_micro_benchmarks.py::test_definition_in_tree
CodSpeed Performance Gauge
0%
5.2 ms
5.2 ms
test_core_future
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_core_future
CodSpeed Performance Gauge
0%
25.2 µs
25.3 µs
test_dict_of_any_core
tests/benchmarks/test_micro_benchmarks.py::test_dict_of_any_core
CodSpeed Performance Gauge
0%
894.1 µs
895.1 µs
test_isinstance_json
tests/benchmarks/test_micro_benchmarks.py::test_isinstance_json
CodSpeed Performance Gauge
0%
20.7 µs
20.8 µs
test_model_core_json
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_model_core_json
CodSpeed Performance Gauge
0%
33.2 µs
33.2 µs
test_complete_core_strict
tests/benchmarks/test_complete_benchmark.py::test_complete_core_strict
CodSpeed Performance Gauge
0%
402.7 µs
404 µs
test_with_default
tests/benchmarks/test_micro_benchmarks.py::test_with_default
CodSpeed Performance Gauge
0%
21.9 µs
22 µs
test_arguments
tests/benchmarks/test_micro_benchmarks.py::test_arguments
CodSpeed Performance Gauge
0%
25.1 µs
25.2 µs
test_list_of_any_core_py
tests/benchmarks/test_micro_benchmarks.py::test_list_of_any_core_py
CodSpeed Performance Gauge
0%
16.7 µs
16.7 µs
test_core_python
tests/benchmarks/test_micro_benchmarks.py::TestModelLarge::test_core_python
CodSpeed Performance Gauge
0%
153.3 µs
153.9 µs
test_bool_core
tests/benchmarks/test_micro_benchmarks.py::test_bool_core
CodSpeed Performance Gauge
0%
24.2 µs
24.4 µs
test_validate_literal[python-few_large_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-few_large_strings]
CodSpeed Performance Gauge
0%
12.1 µs
12.2 µs
test_validate_literal[python-few_ints]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-few_ints]
CodSpeed Performance Gauge
0%
12 µs
12 µs
test_core_string_lax
tests/benchmarks/test_micro_benchmarks.py::test_core_string_lax
CodSpeed Performance Gauge
0%
11.6 µs
11.7 µs
test_date_from_datetime_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_date_from_datetime_str
CodSpeed Performance Gauge
-1%
16.8 µs
16.8 µs
test_json_any_list_str
tests/benchmarks/test_serialization_micro.py::test_json_any_list_str
CodSpeed Performance Gauge
-1%
343.8 µs
345.7 µs
test_raise_error_custom
tests/benchmarks/test_micro_benchmarks.py::test_raise_error_custom
CodSpeed Performance Gauge
-1%
34.7 µs
34.8 µs
test_strict_union_error_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion::test_strict_union_error_core
CodSpeed Performance Gauge
-1%
27.8 µs
28 µs
test_validate_literal[json-many_small_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-many_small_strings]
CodSpeed Performance Gauge
-1%
16.5 µs
16.6 µs
test_validate_literal[json-few_small_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-few_small_strings]
CodSpeed Performance Gauge
-1%
16.5 µs
16.6 µs
test_core_python_fs
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkSimpleModel::test_core_python_fs
CodSpeed Performance Gauge
-1%
109.8 µs
110.6 µs
test_json_any_list_int
tests/benchmarks/test_serialization_micro.py::test_json_any_list_int
CodSpeed Performance Gauge
-1%
327.1 µs
329.5 µs
test_validate_literal[python-many_ints]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-many_ints]
CodSpeed Performance Gauge
-1%
12 µs
12.1 µs
test_isinstance_string_strict_true
tests/benchmarks/test_micro_benchmarks.py::test_isinstance_string_strict_true
CodSpeed Performance Gauge
-1%
11.9 µs
12 µs
test_complete_core_lax
tests/benchmarks/test_complete_benchmark.py::test_complete_core_lax
CodSpeed Performance Gauge
-1%
360.2 µs
362.9 µs
test_validate_literal[python-many_small_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-many_small_strings]
CodSpeed Performance Gauge
-1%
12.1 µs
12.2 µs
test_bytes_core
tests/benchmarks/test_micro_benchmarks.py::test_bytes_core
CodSpeed Performance Gauge
-1%
11.5 µs
11.6 µs
test_variable_tuple
tests/benchmarks/test_micro_benchmarks.py::test_variable_tuple
CodSpeed Performance Gauge
-1%
24.4 µs
24.6 µs
test_model_instance
tests/benchmarks/test_micro_benchmarks.py::test_model_instance
CodSpeed Performance Gauge
-1%
35 µs
35.3 µs
test_chain_nested_functions
tests/benchmarks/test_micro_benchmarks.py::test_chain_nested_functions
CodSpeed Performance Gauge
-1%
28.9 µs
29.1 µs
test_date_from_datetime
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_date_from_datetime
CodSpeed Performance Gauge
-1%
20.5 µs
20.7 µs
test_validate_literal[python-few_mixed]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-few_mixed]
CodSpeed Performance Gauge
-1%
13.4 µs
13.5 µs
test_validate_literal[python-few_str_enum]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-few_str_enum]
CodSpeed Performance Gauge
-1%
13.4 µs
13.5 µs
test_validate_literal[json-few_ints]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-few_ints]
CodSpeed Performance Gauge
-1%
13.3 µs
13.4 µs
test_validate_literal[json-many_ints]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-many_ints]
CodSpeed Performance Gauge
-1%
13.3 µs
13.4 µs
test_validate_literal[json-few_large_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-few_large_strings]
CodSpeed Performance Gauge
-1%
16.8 µs
16.9 µs
test_core_python
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_core_python
CodSpeed Performance Gauge
-1%
25.9 µs
26.1 µs
test_smart_union_coerce_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion::test_smart_union_coerce_core
CodSpeed Performance Gauge
-1%
16 µs
16.1 µs
test_small_class_core_model
tests/benchmarks/test_micro_benchmarks.py::test_small_class_core_model
CodSpeed Performance Gauge
-1%
28.9 µs
29.1 µs
test_core_model_json
tests/benchmarks/test_serialization_micro.py::test_core_model_json
CodSpeed Performance Gauge
-1%
25.8 µs
26 µs
test_chain_two_functions
tests/benchmarks/test_micro_benchmarks.py::test_chain_two_functions
CodSpeed Performance Gauge
-1%
28.8 µs
29.1 µs
test_positional_tuple
tests/benchmarks/test_micro_benchmarks.py::test_positional_tuple
CodSpeed Performance Gauge
-1%
24 µs
24.3 µs
test_date_from_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_date_from_str
CodSpeed Performance Gauge
-1%
15 µs
15.1 µs
test_validate_literal[json-few_str_enum]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-few_str_enum]
CodSpeed Performance Gauge
-1%
18.4 µs
18.6 µs
test_validate_literal[python-many_large_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[python-many_large_strings]
CodSpeed Performance Gauge
-1%
12.1 µs
12.2 µs
test_isinstance_string_lax_true
tests/benchmarks/test_micro_benchmarks.py::test_isinstance_string_lax_true
CodSpeed Performance Gauge
-1%
11.8 µs
11.9 µs
test_core_string_strict_wrong
tests/benchmarks/test_micro_benchmarks.py::test_core_string_strict_wrong
CodSpeed Performance Gauge
-1%
23.9 µs
24.1 µs
test_raise_error_value_error
tests/benchmarks/test_micro_benchmarks.py::test_raise_error_value_error
CodSpeed Performance Gauge
-1%
33.9 µs
34.3 µs
test_chain_list
tests/benchmarks/test_micro_benchmarks.py::test_chain_list
CodSpeed Performance Gauge
-1%
25.5 µs
25.7 µs
test_chain_function
tests/benchmarks/test_micro_benchmarks.py::test_chain_function
CodSpeed Performance Gauge
-1%
25 µs
25.2 µs
test_core_string_strict_wrong_str_e
tests/benchmarks/test_micro_benchmarks.py::test_core_string_strict_wrong_str_e
CodSpeed Performance Gauge
-1%
39.3 µs
39.7 µs
test_validate_literal[json-many_large_strings]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-many_large_strings]
CodSpeed Performance Gauge
-1%
16.8 µs
17 µs
test_core_json_fs
tests/benchmarks/test_micro_benchmarks.py::TestModelLarge::test_core_json_fs
CodSpeed Performance Gauge
-1%
191.7 µs
193.8 µs
test_small_class_core_dict
tests/benchmarks/test_micro_benchmarks.py::test_small_class_core_dict
CodSpeed Performance Gauge
-1%
18.2 µs
18.4 µs
test_core_future_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_core_future_str
CodSpeed Performance Gauge
-1%
15.2 µs
15.4 µs
test_json_direct_list_str
tests/benchmarks/test_serialization_micro.py::test_json_direct_list_str
CodSpeed Performance Gauge
-1%
213 µs
215.5 µs
test_model_instance_abc
tests/benchmarks/test_micro_benchmarks.py::test_model_instance_abc
CodSpeed Performance Gauge
-1%
36.8 µs
37.3 µs
test_validate_literal[json-few_mixed]
tests/benchmarks/test_micro_benchmarks.py::test_validate_literal[json-few_mixed]
CodSpeed Performance Gauge
-1%
14.9 µs
15 µs
test_model_list_core_json
tests/benchmarks/test_serialization_micro.py::test_model_list_core_json
CodSpeed Performance Gauge
-1%
213 µs
215.5 µs
test_date_from_date
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_date_from_date
CodSpeed Performance Gauge
-1%
11.8 µs
11.9 µs
test_generator_python
tests/benchmarks/test_micro_benchmarks.py::test_generator_python
CodSpeed Performance Gauge
-1%
27.8 µs
28.1 µs
test_dont_raise_error
tests/benchmarks/test_micro_benchmarks.py::test_dont_raise_error
CodSpeed Performance Gauge
-1%
18.2 µs
18.4 µs
test_core_string_lax_wrong
tests/benchmarks/test_micro_benchmarks.py::test_core_string_lax_wrong
CodSpeed Performance Gauge
-1%
24.1 µs
24.4 µs
test_int_error
tests/benchmarks/test_micro_benchmarks.py::test_int_error
CodSpeed Performance Gauge
-1%
44.1 µs
44.7 µs
test_smart_union_core
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkUnion::test_smart_union_core
CodSpeed Performance Gauge
-1%
14.8 µs
15 µs
test_generator_rust
tests/benchmarks/test_micro_benchmarks.py::test_generator_rust
CodSpeed Performance Gauge
-1%
18.5 µs
18.7 µs
test_dont_raise_error_no_info
tests/benchmarks/test_micro_benchmarks.py::test_dont_raise_error_no_info
CodSpeed Performance Gauge
-1%
16.2 µs
16.5 µs
test_json_direct_list_int
tests/benchmarks/test_serialization_micro.py::test_json_direct_list_int
CodSpeed Performance Gauge
-1%
197.3 µs
200.3 µs
test_tuple_many_positional
tests/benchmarks/test_micro_benchmarks.py::test_tuple_many_positional
CodSpeed Performance Gauge
-2%
18.9 µs
19.2 µs
test_model_exclude_unset_true
tests/benchmarks/test_serialization_micro.py::test_model_exclude_unset_true
CodSpeed Performance Gauge
-2%
36.9 µs
37.5 µs
test_core_future_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_core_future_str
CodSpeed Performance Gauge
-2%
18.1 µs
18.4 µs
test_to_string_format
tests/benchmarks/test_serialization_micro.py::test_to_string_format
CodSpeed Performance Gauge
-2%
22.8 µs
23.2 µs
test_core_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime::test_core_str
CodSpeed Performance Gauge
-2%
17.7 µs
18.1 µs
test_tuple_many_variable
tests/benchmarks/test_micro_benchmarks.py::test_tuple_many_variable
CodSpeed Performance Gauge
-2%
18.5 µs
18.9 µs
test_core_future
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX::test_core_future
CodSpeed Performance Gauge
-2%
16.8 µs
17.1 µs
test_datetime
tests/benchmarks/test_serialization_micro.py::test_datetime
CodSpeed Performance Gauge
-2%
27.2 µs
27.8 µs
test_to_string_direct
tests/benchmarks/test_serialization_micro.py::test_to_string_direct
CodSpeed Performance Gauge
-2%
18.1 µs
18.6 µs
test_core_json
tests/benchmarks/test_serialization_micro.py::TestBenchmarkSimpleModel::test_core_json
CodSpeed Performance Gauge
-4%
101.9 µs
105.8 µs

Commits

Click on a commit to change the comparison range
Base
main
d3f97e7
-32%
support __pydantic_extra__ when serializing
e416bf8
2 years ago
by samuelcolvin
+2%
support __pydantic_extra__ when serializing
551fa1f
2 years ago
by samuelcolvin
-1%
customising fields
193b998
2 years ago
by samuelcolvin
-1%
custom pydantic_extra behaviour
485bc45
2 years ago
by samuelcolvin
+3%
moving to separate fields serializer
07b7d10
2 years ago
by samuelcolvin
0%
fix benchmarks schemas
f467aac
2 years ago
by samuelcolvin
-4%
fix json serialization of extra
ad7974e
2 years ago
by samuelcolvin
+32%
improve field handling
3e1fb94
2 years ago
by samuelcolvin
0%
__pydantic_extra__ alwasy a dict if extra=allow
38630f6
2 years ago
by samuelcolvin
+1%
tests for extra filtering
0d1712d
2 years ago
by samuelcolvin
0%
fix issue with config merging
0fa626f
2 years ago
by samuelcolvin
© 2025 CodSpeed Technology
Home Terms Privacy Docs