René's URL Explorer Experiment


Title: Performance [P2]: Cache type-discovery signature structure by berndverst · Pull Request #207 · microsoft/durabletask-python · GitHub

Open Graph Title: Performance [P2]: Cache type-discovery signature structure by berndverst · Pull Request #207 · microsoft/durabletask-python

X Title: Performance [P2]: Cache type-discovery signature structure by berndverst · Pull Request #207 · microsoft/durabletask-python

Description: Summary durabletask/internal/type_discovery.py cached resolved type hints, but _input_annotation() and activity_output_type() still called inspect.signature() and re-filtered positional parameters on every invocation. Discovery runs once per work item — activity execution, entity operation, and every orchestration replay of call_activity — so small, high-frequency handlers repeatedly paid reflection costs. The signature structure (positional parameters in declaration order plus the return annotation) and the resolved annotations are a pure function of the callable, so they are now computed once and memoized in a bounded functools.lru_cache (same maxsize=2048 bound and rationale as the existing resolved-hints cache). Correctness DataConverter.can_reconstruct() is not part of the cached value. It is still evaluated on every call, so a different — or stateful — converter continues to produce its own per-call decision for the same function. All existing resolution semantics are preserved bit-for-bit: unannotated parameters, *args / **kwargs and keyword-only parameters (still not positional inputs), Any, PEP 563 / string postponed annotations that cannot be resolved, plain functions vs. unbound entity methods, and the conservative fallback to the raw payload when resolution fails. A dedicated _NO_ANNOTATION sentinel is used instead of None so that a literal None annotation still reaches the converter exactly as before. Callables that cannot be used as a cache key (unhashable) fall back to an uncached computation, so caching never narrows the set of callables that discovery supports. Previously such callables raised TypeError from the hints cache. No public API change, no renames, no changed import paths. One observable behavior change, surfaced in review: a handler that is an unhashable callable — most realistically a @dataclass with __call__, since dataclasses default to eq=True and so set __hash__ = None — previously raised TypeError: unhashable type out of the memoized hint lookup during type discovery. Such handlers reach the worker through add_named_activity() / add_named_orchestrator() / add_named_entity(), which take an explicit name and so do not require __name__. They now resolve their annotations normally. This is covered by a CHANGELOG entry under Unreleased / FIXED and pinned by a test through the public registration API. Performance Steady-state cost per call for def act(ctx, order: Order) -> Order (dataclass input/output, caches warm, 100k iterations): helper before after speedup activity_input_type 10.190 us 0.885 us 11.5x activity_output_type 9.119 us 0.813 us 11.2x The residual ~0.8 us is dominated by can_reconstruct(), which is intentionally still per-call. Verification Core unit tests: pytest tests/durabletask -q --ignore-glob="*_e2e.py" -> 688 passed, 7 skipped (baseline on main was 681 tests; the 7 new tests account for the difference). Provider unit tests: pytest tests/durabletask-azuremanaged/test_sandboxes_extension.py tests/durabletask-azuremanaged/test_durabletask_grpc_interceptor.py -q -> 42 passed. flake8 clean on both changed files; pyright (strict, project config) reports 0 issues for durabletask/internal/type_discovery.py. New tests in tests/durabletask/test_type_discovery.py (all 7 verified to fail or be meaningless against the pre-change implementation): inspect.signature() is invoked once per callable and never again, for both the input and output helpers and for class-based entity operations. Priming the cache with a converter that recognizes a type and then querying with the default converter returns the correct different answer (both orders, input and output). A stateful converter that flips its can_reconstruct answer between calls is honored on every call. The converter is consulted on every call, and never for unannotated parameters. Unhashable callables still resolve. Fixes #189

Open Graph Description: Summary durabletask/internal/type_discovery.py cached resolved type hints, but _input_annotation() and activity_output_type() still called inspect.signature() and re-filtered positional parameters ...

X Description: Summary durabletask/internal/type_discovery.py cached resolved type hints, but _input_annotation() and activity_output_type() still called inspect.signature() and re-filtered positional parameters ...

Opengraph URL: https://github.com/microsoft/durabletask-python/pull/207

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a695c0d1-d12d-ed64-fe51-333a4c3fa186
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA2D8:2CAD0F:43483:54621:6AFE414C
html-safe-nonce93cfc3716335ea2fb180721829d70ae5a63ec195dff6aae076b30c11120bc79b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkQ4OjJDQUQwRjo0MzQ4Mzo1NDYyMTo2QUZFNDE0QyIsInZpc2l0b3JfaWQiOiI5MDc3MTIxNjY3NzEyMzAzNDM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf2dfbb3c56dd77785258c4c88671a2d94b8958745b59d317f5d6275948218617
hovercard-subject-tagpull_request:4139791674
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/207/files
twitter:imagehttps://avatars.githubusercontent.com/u/4535280?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4535280?s=400&v=4
og:image:altSummary durabletask/internal/type_discovery.py cached resolved type hints, but _input_annotation() and activity_output_type() still called inspect.signature() and re-filtered positional parameters ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id627664515
octolytics-dimension-repository_nwomicrosoft/durabletask-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627664515
octolytics-dimension-repository_network_root_nwomicrosoft/durabletask-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec4447fdce9ed0f33af959d2b6680d0bc18212a6a
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/durabletask-python/pull/207/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F207%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F207%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=microsoft%2Fdurabletask-python
Reloadhttps://github.com/microsoft/durabletask-python/pull/207/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/207/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/207/files
microsofthttps://github.com/microsoft
durabletask-pythonhttps://github.com/microsoft/durabletask-python
Codehttps://github.com/microsoft/durabletask-python
Issues15 (15)https://github.com/microsoft/durabletask-python/issues
Pull requests12 (12)https://github.com/microsoft/durabletask-python/pulls
Actionshttps://github.com/microsoft/durabletask-python/actions
Projectshttps://github.com/microsoft/durabletask-python/projects
Security and qualityhttps://github.com/microsoft/durabletask-python/security
Insightshttps://github.com/microsoft/durabletask-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
Bernd Verst (berndverst)https://github.com/berndverst
mainhttps://github.com/microsoft/durabletask-python/tree/main
berndverst-cache-type-discovery-signaturehttps://github.com/microsoft/durabletask-python/tree/berndverst-cache-type-discovery-signature
Conversation 21 https://github.com/microsoft/durabletask-python/pull/207
Commits 6 https://github.com/microsoft/durabletask-python/pull/207/commits
Checks 24 https://github.com/microsoft/durabletask-python/pull/207/checks
Files changed https://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Performance [P2]: Cache type-discovery signature structure https://github.com/microsoft/durabletask-python/pull/207/files#top
Show all changes 6 commits https://github.com/microsoft/durabletask-python/pull/207/files
0070019 Cache type-discovery signature structure Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/0070019cfd88e98da734fa26838216e8a5a519be
7c9392e Merge remote-tracking branch 'origin/main' into berndverst-cache-type… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/7c9392ee76cfda6ad8814388d7c2dcf20ce63356
2fae7ae Merge remote-tracking branch 'origin/main' into berndverst-cache-type… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/2fae7aee477143827e96d78fd41a3f812ba8406f
27c4dfa Merge remote-tracking branch 'origin/main' into berndverst-cache-type… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/27c4dfacfa0b0babc948a6defdbc747d3c77147b
4203412 Address review feedback on type-discovery caching Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/4203412c6497e88f2ce2930f5b258f13e679e099
e0ef511 Merge remote-tracking branch 'origin/main' into berndverst-cache-type… Jul 27, 2026 https://github.com/microsoft/durabletask-python/pull/207/commits/e0ef51199c68826cfe4ce77b1de921aab5b1e507
Clear filters https://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
CHANGELOG.md https://github.com/microsoft/durabletask-python/pull/207/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
type_discovery.py https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
test_type_discovery.py https://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
CHANGELOG.mdhttps://github.com/microsoft/durabletask-python/pull/207/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
View file https://github.com/microsoft/durabletask-python/blob/e0ef51199c68826cfe4ce77b1de921aab5b1e507/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/207/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/207/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
https://github.com/microsoft/durabletask-python/pull/207/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
durabletask/internal/type_discovery.pyhttps://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
View file https://github.com/microsoft/durabletask-python/blob/e0ef51199c68826cfe4ce77b1de921aab5b1e507/durabletask/internal/type_discovery.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/207/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
https://github.com/microsoft/durabletask-python/pull/207/files#diff-23136fceef96c7a275b8a54881fea54fef7bbcf6cc0cc902442e29f87951f99c
tests/durabletask/test_type_discovery.pyhttps://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
View file https://github.com/microsoft/durabletask-python/blob/e0ef51199c68826cfe4ce77b1de921aab5b1e507/tests/durabletask/test_type_discovery.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/207/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
https://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
https://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
https://github.com/microsoft/durabletask-python/pull/207/files#diff-61c92b625a9197ef63e9f0e5b32ab7b7e8f08bba32005ac6eca2fc0613033a39
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/207/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.