Repository navigation
Skip generic check in StrawberryAnnotation.resolve() without a type definition - #4790
Conversation
|
Thanks for adding the Below is the changelog that will be used for the release. This release improves the performance of argument conversion by skipping an This release was contributed by @fernandoflorez in #4790 |
[Low impact] This PR appears safe to merge. SummaryThis PR skips
No actionable issues were found. Reviews (1) · Last reviewed commit: "Skip generic check in StrawberryAnnotati..." · Reviewed by Greptile |
bellini666
left a comment
There was a problem hiding this comment.
Small and effective, love it ❤️
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
StrawberryAnnotation.resolve()checks_is_type_generic(resolved)beforetype_definition is not None. When there's no type definition the result isalways false, but the generic check still runs.
That happens a lot:
convert_argumentsreadsargument.type(which callsresolve()with no type definition) for every argument on every fieldexecution. Swapping the two conditions skips the check in that case; the
behavior doesn't change, since without a type definition
resolve()justreturns the cached type.
In a list-heavy query I was profiling (fields with arguments on each item),
this gave a 2–8% speedup in execution time.
Added a test checking that
_is_type_genericisn't called when there's notype definition.
Summary by Sourcery
Optimize annotation resolution for argument conversion without changing its behavior.
Enhancements:
Tests: