seandstewart / typical

Typical: Fast, simple, & correct data-validation using Python 3 typing.
https://python-typical.org
MIT License
182 stars 9 forks source link

Fix Bottleneck when Handling Recursive Types #118

Closed seandstewart closed 4 years ago

seandstewart commented 4 years ago

As part of the changes to handle recursive types, we added recursion detection. We re-worked it in the last version to minimize its impact. However, it was still significantly hampering performance at compile-time.

This resolves that bottleneck by removing the recursion check and adding awareness of "parent" types when resolving constraints and schemas.

codecov[bot] commented 4 years ago

Codecov Report

Merging #118 into master will decrease coverage by 0.23%. The diff coverage is 87.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #118      +/-   ##
==========================================
- Coverage   96.69%   96.46%   -0.24%     
==========================================
  Files          36       36              
  Lines        3815     3842      +27     
==========================================
+ Hits         3689     3706      +17     
- Misses        126      136      +10     
Flag Coverage Δ
#3.7 96.40% <87.64%> (-0.22%) :arrow_down:
#3.8 96.45% <87.91%> (-0.24%) :arrow_down:
#unittests 96.46% <87.91%> (-0.24%) :arrow_down:
Impacted Files Coverage Δ
typic/constraints/array.py 98.75% <ø> (ø)
typic/constraints/mapping.py 98.86% <ø> (-0.57%) :arrow_down:
typic/klass.py 100.00% <ø> (+2.32%) :arrow_up:
typic/util.py 94.09% <ø> (+0.78%) :arrow_up:
typic/ext/schema/schema.py 88.42% <78.72%> (-1.03%) :arrow_down:
typic/serde/resolver.py 92.10% <88.88%> (-0.72%) :arrow_down:
typic/constraints/common.py 92.83% <100.00%> (-2.93%) :arrow_down:
typic/constraints/factory.py 100.00% <100.00%> (+2.98%) :arrow_up:
typic/ext/schema/field.py 99.27% <100.00%> (+<0.01%) :arrow_up:
typic/serde/common.py 94.54% <100.00%> (-0.30%) :arrow_down:
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6ab0ff0...02f0cc1. Read the comment docs.