Skip to content

Improve performance of _typing_extra module#11255

Merged
Viicos merged 2 commits intomainfrom
typing-extra-perf
Jan 10, 2025
Merged

Improve performance of _typing_extra module#11255
Viicos merged 2 commits intomainfrom
typing-extra-perf

Conversation

@Viicos
Copy link
Copy Markdown
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
@cloudflare-workers-and-pages
Copy link
Copy Markdown

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
@codspeed-hq
Copy link
Copy Markdown

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
Comment thread pydantic/_internal/_typing_extra.py Outdated
@github-actions
Copy link
Copy Markdown
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

Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
```
"""
return _is_typing_name(tp, name='Any')
return tp is typing.Any or tp is t_e.Any
Copy link
Copy Markdown
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?

Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
Comment thread pydantic/_internal/_typing_extra.py Outdated
Copy link
Copy Markdown
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!

Comment thread pydantic/_internal/_typing_extra.py Outdated
@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
@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