Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use chain.from_iterable in class_validators.py #1642

Merged
merged 2 commits into from Jun 27, 2020

Conversation

cool-RR
Copy link
Contributor

@cool-RR cool-RR commented Jun 17, 2020

This is a faster and more idiomatic way of using itertools.chain. Instead of computing all the items in the iterable and storing them in memory, they are computed one-by-one and never stored as a huge list. This can save on both runtime and memory space.

@codecov
Copy link

codecov bot commented Jun 17, 2020

Codecov Report

Merging #1642 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##            master    #1642      +/-   ##
===========================================
- Coverage   100.00%   99.94%   -0.06%     
===========================================
  Files           21       21              
  Lines         3798     3799       +1     
  Branches       752      756       +4     
===========================================
- Hits          3798     3797       -1     
- Misses           0        1       +1     
- Partials         0        1       +1     
Impacted Files Coverage Δ
pydantic/class_validators.py 100.00% <ø> (ø)
pydantic/networks.py 99.21% <0.00%> (-0.79%) ⬇️
pydantic/types.py 100.00% <0.00%> (ø)
pydantic/fields.py 100.00% <0.00%> (ø)
pydantic/typing.py 100.00% <0.00%> (ø)
pydantic/validators.py 100.00% <0.00%> (ø)
pydantic/dataclasses.py 100.00% <0.00%> (ø)

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 0cee311...17029f3. Read the comment docs.

@samuelcolvin
Copy link
Member

Seems reasonable, please could you add a change description, also are we calling chain() anywhere else?

@cool-RR cool-RR marked this pull request as ready for review June 17, 2020 09:48
@cool-RR
Copy link
Contributor Author

cool-RR commented Jun 17, 2020

Added change description. No, this is the only instance of this issue.

@cool-RR
Copy link
Contributor Author

cool-RR commented Jun 21, 2020

@samuelcolvin Are we good for merging?

@samuelcolvin
Copy link
Member

Yes, I just have a lot on at the moment. I'll get to this PR when I have time.

@samuelcolvin samuelcolvin merged commit ecb54c5 into pydantic:master Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants