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
Use PEP 590 vectorcall to speed up GenericAlias. #84549
Comments
Since PEP-560 was approved, from queue import Queue
v = Queue[int] It's a very shiny feature. When I looked at Object/geneticiasobject.c, the current implementation is a very good condition for using the vectorcall proposed by PEP-590 . The benchmarks are as follows. if the suggestion is accepted, I 'd like to summit the patch :) +--------------------+----------------------+-----------------------------+ |
Can you propose a PR, so I can have a look at the implementation? |
Got it :), I will upload it soon. |
I have doubts that GenericAlias instances are created in mass in tight loops. Do you have any realistic example which would benefit from speeding up creation of GenericAlias instances? |
Hmm I did not find loop tightly calling case, but def create_q(l: list[int]) -> Queue[int]:
q = Queue[int]()
for e in l:
q.put(e)
return q
a = create_q([1,2,3,4,5]) In this code, GenericAlias is called 2 times for function declare and function call. It's true that GenericAlias has a small portion in this scenario, |
And how much faster has your example become? |
For function declaration, 5% enhancement, +--------------------+------------------------+----------------------------+ |
Just for the record, guido left an opinion that the caching approach might be more proper. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: