Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add experimental support for free threading#11516

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Viicos merged 9 commits intomainfromfreethreaded
Mar 11, 2025
Merged

Add experimental support for free threading#11516

Viicos merged 9 commits intomainfromfreethreaded
Mar 11, 2025

Conversation

Viicos
Copy link
Member

Change Summary

Fixes#10483.

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

Similar logic to the recursion state
Nothing we can really do on these ones, the `generate_schema_calls`fixture monkeypatches code and this will happen across threads.
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelMar 3, 2025
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedMar 3, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:03d03fd
Status: ✅  Deploy successful!
Preview URL:https://fdfb6bc1.pydantic-docs.pages.dev
Branch Preview URL:https://freethreaded.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedMar 3, 2025
edited
Loading

CodSpeed Performance Report

Merging#11516 willnot alter performance

Comparingfreethreaded (03d03fd) withmain (50a7269)

Summary

✅ 46 untouched benchmarks

@@ -2149,6 +2150,7 @@ class Yard(BaseModel):
assert str(yard_dict['pet']['type']) == 'dog'


@pytest.mark.thread_unsafe(reason='Passes on multithreaded. This needs to be investigated further.')
Copy link
MemberAuthor

@ViicosViicosMar 3, 2025
edited
Loading

Choose a reason for hiding this comment

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

While all the other tests marked as thread unsafe made sense, I have no idea why this one passes. Core schemas are identical, and verified it isn't a late lambda binding issue. Might be something in core?

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedMar 4, 2025
edited
Loading

Coverage report

Click to see where and how coverage changed

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

This report was generated bypython-coverage-comment-action

@ViicosViicos changed the titleAdd support for freethreadingAdd initial support for freethreadingMar 4, 2025
@ViicosViicos changed the titleAdd initial support for freethreadingAdd experimental support for freethreadingMar 5, 2025
@ViicosViicos added relnotes-feature and removed relnotes-fixUsed for bugfixes. labelsMar 5, 2025
Copy link
Contributor

@davidhewittdavidhewitt left a comment

Choose a reason for hiding this comment

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

Overall LGTM with one question!

@@ -94,7 +94,7 @@ def __delitem__(self, key: KT) -> None:
# and discover later on that we need to re-add all this infrastructure...
# _GENERIC_TYPES_CACHE = DeepChainMap(GenericTypesCache(), LimitedDict())

_GENERIC_TYPES_CACHE = GenericTypesCache()
_GENERIC_TYPES_CACHE: ContextVar[GenericTypesCache | None] = ContextVar('_GENERIC_TYPES_CACHE', default=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

The idea here is to make a separate cache for each thread?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes exactly, identical to the recursion cache:

_generic_recursion_cache:ContextVar[set[str]|None]=ContextVar('_generic_recursion_cache',default=None)

davidhewitt reacted with thumbs up emoji
@sydney-runkle
Copy link
Contributor

Makes sense to get this into the 2nd beta next week 👍

@ViicosViicos changed the titleAdd experimental support for freethreadingAdd experimental support for free threadingMar 11, 2025
@ViicosViicos merged commit10af6a8 intomainMar 11, 2025
62 checks passed
@ViicosViicos deleted the freethreaded branchMarch 11, 2025 15:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@davidhewittdavidhewittdavidhewitt approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Python 3.13 freethreading support
3 participants
@Viicos@sydney-runkle@davidhewitt

[8]ページ先頭

©2009-2025 Movatter.jp