-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Implement types._GeneratorWrapper in C #133372
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
Comments
Please, before diving to deep into it: explain what we will achieve by doing so. For example: performance (and in what cases). Also: take extra care about potential compatibility changes. |
Actually, base PR is already present, I've linked it. Second is PyCoroWrapper in genobject.c which wraps generator object. I don't think that performance gain is big, mainly because _GeneratorWrapper is only used in types.coroutine decorator. I also slightly improve pure Python implementation of _GeneratorWrapper: gi_suspended and cr_suspended properties are added. Speaking about compatibility, I can see no problems, because C version is very close to pure Python version. |
Moreover, there is another "TODO: Implement this in C." line in this file: Line 308 in a247dd3
It seems that types.coroutine also should be implemented both in C and in Python. |
I tried this a few months ago on my own, and from that experience, I'm really concerned about this change.
|
How fast are we in terms of import time however? Here it's interesting to see if we can improve the import time of |
I also fear that we might introduce some bugs with the rewrite. Since Unless we see a really good reasoning. |
Would it be worth considering deprecating In the top 10,000 PyPI projects, it's only used in 91: Of these, the uses in A Footnotes
|
I think we can do that for 3.15, it would mark 10 versions of |
asyncio doesn't support generator based coroutines anymore so optimizing this isn't worth it. I think the comment should be removed as it is not relevant nowadays. |
IMO, this is very good question, and we could consider it in the details. I should learn these code snippets deeply to better understand the current situation. |
also cc @njsmith. Both the examples cited by Nathaniel are 'simple' cases where all A |
I've started a discussion about deprecation: |
I don't there is any benefit of changing or deprecating it, there are valid use cases for it and I think it's best to just remove the comment of implementing it in C and close this issue. |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
I've found an old TODO line in types module and decided to give it a try:
https://github.com/python/cpython/blob/main/Lib/types.py#L253
My PR with this change will be linked soon.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: