I was benchmarking a render and I noticed that the use of `inspect.isawaitable` really slows things down: ``` ncalls tottime percall cumtime percall filename:lineno(function) 22920 0.024 0.000 0.059 0.000 .../python3.10/inspect.py:348(isawaitable) ``` Almost 60 milliseconds is spent there, more than any other Python builtin in the profile. <!-- Describe how to replicate the bug. Include a minimal reproducible example that demonstrates the bug. Include the full traceback if there was an exception. --> <!-- Describe the expected behavior that should have happened but didn't. --> Environment: - Python version: 3.10 - Jinja version: 3.0.1
Activity
davidism commentedon Oct 16, 2021
Sounds like something that should be reported to CPython so they can improve its performance. I don't see what Jinja could do about this.
mohd-akram commentedon Oct 16, 2021
I'm getting anywhere between 15% to 2x improvement with this change:
Since most objects are primitives, we can avoid a costly check.
davidism commentedon Oct 16, 2021
Happy to review a PR.