8000 Improve performance of `_typing_extra` module by Viicos · Pull Request #11255 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Improve performance of _typing_extra module #11255

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

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Improve performance of _typing_extra module #11255

merged 2 commits into from
Jan 10, 2025

Conversation

Viicos
Copy link
Member
@Viicos Viicos commented Jan 10, 2025

Change Summary

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Jan 10, 2025
Copy link
cloudflare-workers-and-pages bot commented Jan 10, 2025

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6f56712
Status: ✅  Deploy successful!
Preview URL: https://e27b80b8.pydantic-docs.pages.dev
Branch Preview URL: https://typing-extra-perf.pydantic-docs.pages.dev

View logs

@Viicos Viicos force-pushed the typing-extra-perf branch from 9dc2303 to 48fc1d3 Compare January 10, 2025 18:13
Copy link
codspeed-hq bot commented Jan 10, 2025

CodSpeed Performance Report

Merging #11255 will not alter performance

Comparing typing-extra-perf (6f56712) with main (e9ff00c)

Summary

✅ 45 untouched benchmarks

@Viicos Viicos force-pushed the typing-extra-perf branch from 48fc1d3 to c219e23 Compare January 10, 2025 18:21
Copy link
Contributor
github-actions bot commented Jan 10, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _typing_extra.py
Project Total  

This report was generated by python-coverage-comment-action

@@ -58,7 +40,7 @@ def is_any(tp: Any, /) -> bool:
#> True
```
"""
return _is_typing_name(tp, name='Any')
return tp is typing.Any or tp is t_e.Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth importing everything by name and avoiding the attribute access, in my test it reduced the time from about 30ns to 20ns?

Copy link
Contributor
@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great otherwise!

@sydney-runkle sydney-runkle added relnotes-performance Used for performance improvements. and removed relnotes-fix Used for bugfixes. labels Jan 10, 2025
@Viicos Viicos merged commit 8ef33a0 into main Jan 10, 2025
62 checks passed
@Viicos Viicos deleted the typing-extra-perf branch January 10, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-performance Used for performance improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0