-
-
Notifications
You must be signed in to change notification settings - Fork 602
Add custom is_awaitable to test perf #4035
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR introduces a custom optimized_is_awaitable function for faster awaitability checks on primitive types and integrates it into the GraphQL execution flow by passing it to both async and sync execution methods. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4035 +/- ##
=======================================
Coverage 94.39% 94.39%
=======================================
Files 534 536 +2
Lines 34834 34849 +15
Branches 1831 1832 +1
=======================================
+ Hits 32881 32896 +15
Misses 1657 1657
Partials 296 296 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #4035 will improve performances by 10.58%Comparing Summary
Benchmarks breakdown
|
| # For other types, use the standard graphql-core logic | ||
| # This handles coroutines, generators, and custom awaitable objects | ||
| return ( | ||
| # check for coroutine objects | ||
| isinstance(value, CoroutineType) | ||
| # check for old-style generator based coroutine objects | ||
| or ( | ||
| isinstance(value, GeneratorType) | ||
| and bool(value.gi_code.co_flags & CO_ITERABLE_COROUTINE) | ||
| ) | ||
| # check for other awaitables (e.g. futures) | ||
| or hasattr(value, "__await__") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: The difference between this and https://github.com/graphql-python/graphql-core/blob/main/src/graphql/pyutils/is_awaitable.py#L20-L20 is the fast path, right?
We can possibly just import it from graphql-core and return graphql_core_is_awaitable(value) here, so we don't need to redefine this "not so obvious" code
Summary by Sourcery
Integrate a new optimized is_awaitable implementation into the GraphQL execution pipeline to reduce overhead when handling large result sets of primitive values.
New Features:
Enhancements: