GeezerVison is showing github.com — bpo-1635741: Port _asyncio extension module to multiphase initialization(PEP 489) by shihai1991 · Pull Request #18032 · python/cpython
Conversation
shihai1991
commented
Jan 16, 2020
•
edited by bedevere-bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Should multiphase support m_traverse/m_clear along with m_free?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
shihai1991
commented
Jan 17, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Should multiphase support m_traverse/m_clear along with m_free?
From pep 489: If the Py_mod_create function does not return a module subclass, then m_size must be 0, and m_traverse, m_clear and m_free must all be NULL. Otherwise, SystemError is raised.
Looks I overlooked the detail.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@asvetlov Hi, andrew. I checked pep 0489 again. IMHO, supporting m_traverse/m_clear should be pep 3121's content.
cc @encukou @Dormouse759
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
My question is not about the exact PEP number but the correctness.
Currently, _asyncio has very many static C variables to keep references to other Python objects.
From my understanding, multiphase compatible module should support releasing these resources by m_free call. Since stored objects potentially can make cycles, m_traverse and m_clear are required as well.
Did I miss something?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I'm not available this week, so just a quick comment based on a superficial reading of this PEP:
@shihai1991, PEPs 3121 and 489 are historical documents from 2007 and 2013. Any additional information should go in the Python documentation.
Could you file a ticket to add any missing info?
@asvetlov You are right. Also, with multiphase init, multiple module objects can be created from the same extension code. That can cause problems, especially if any of the static variables are mutable or created unconditionally on module initialization.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@encukou thanks for the clarification. if (static_var != NULL) {static_var = init_var();} should be enough for _asyncio needs.
I know, module-level storage for static vars is even better but I'd like to postpone it to PEP 573 landing at least. _Py_IDENTIFIER(id) is another questionable point.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I know, module-level storage for static vars is even better but I'd like to postpone it to PEP 573 landing at least. _Py_IDENTIFIER(id) is another questionable point.
+1.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@encukou thanks for your comment, petr. PEP is fine to me now and I need spend much time to understand all the historical iterations of extension module's loading ;)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I close this PR temporarily because it's depend on much future work.
Thank you for everybody's comment.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
1st1
Awaiting requested review from 1st1
asvetlov
Awaiting requested review from asvetlov
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|