Avatar for the pydantic user
pydantic
pydantic-core
BlogDocsChangelog

improve performance of recursion guard

#1156Merged
Comparing
recursion-guard-speedups
(
4b82950
) with
main
(
d7cf72d
)
CodSpeed Performance Gauge
-15%
Improvement
4
Regression
2
Untouched
137

Benchmarks

143 total
test_core_future
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX
CodSpeed Performance Gauge
-15%
19.8 µs23.5 µs
test_core_future_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateTime
CodSpeed Performance Gauge
-14%
21.5 µs25 µs
test_definition_out_of_tree
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+22%
1.3 ms1.1 ms
test_json_any_list_int
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+18%
252 µs214.1 µs
test_to_json_list_of_lists
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+15%
2.3 ms2 ms
test_json_any_list_str
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+15%
288 µs251.1 µs
test_validate_literal[json-few_small_strings]
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+7%
17.7 µs16.5 µs
test_chain_nested_functions
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+5%
28.7 µs27.4 µs
test_core_model_py_extra
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+4%
32.8 µs31.6 µs
test_core_model_json_extra
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+4%
31.9 µs30.8 µs
test_filter
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+4%
46.7 µs45.1 µs
test_isinstance_json
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+3%
22.3 µs21.7 µs
test_chain_two_functions
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+3%
30.3 µs29.5 µs
test_field_function_validator
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
405 µs395.5 µs
test_date_from_str
tests/benchmarks/test_micro_benchmarks.py::TestBenchmarkDateX
CodSpeed Performance Gauge
+2%
18.8 µs18.3 µs
test_datetime
tests/benchmarks/test_serialization_micro.py
CodSpeed Performance Gauge
+2%
30.1 µs29.5 µs
test_core_string_strict
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
13.7 µs13.4 µs
test_set_of_ints_core
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
790.4 µs773.8 µs
test_nested_schema_using_defs
tests/benchmarks/test_nested_benchmark.py
CodSpeed Performance Gauge
+2%
20.4 ms20 ms
test_set_of_ints_core_length
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
801.5 µs785.6 µs
test_isinstance_string_strict_false
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
15.2 µs15 µs
test_strict_int
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
13.8 µs13.5 µs
test_dict_of_any_core
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
776 µs761.8 µs
test_set_of_ints_core_json_duplicates
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
715.6 µs702.6 µs
test_core_string_lax
tests/benchmarks/test_micro_benchmarks.py
CodSpeed Performance Gauge
+2%
13.7 µs13.5 µs

Commits

Click on a commit to change the comparison range
Base
main
d7cf72d
+15.06%
tweak depth limit logic
5d14e70
2 years ago
by samuelcolvin
-0.17%
bump
3e73e52
2 years ago
by samuelcolvin
-1.46%
bump
3a621b7
2 years ago
by samuelcolvin
+10.12%
tidy up `contains_or_insert` to be more efficient
3f72522
2 years ago
by davidhewitt
+4.8%
remove cargo.toml release profile change
e1190ed
2 years ago
by samuelcolvin
-43.8%
codify the stack-based nature of the guard
4b82950
2 years ago
by davidhewitt
© 2026 CodSpeed Technology
Home Terms Privacy Docs