-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
bpo-40428: Remove PyTuple_ClearFreeList() function #19769
Conversation
Remove the following function from the C API: * PyAsyncGen_ClearFreeLists() * PyContext_ClearFreeList() * PyDict_ClearFreeList() * PyFloat_ClearFreeList() * PyFrame_ClearFreeList() * PyList_ClearFreeList() * PySet_ClearFreeList() * PyTuple_ClearFreeList() Make these functions private, move them to the internal C API and change their return type to void. Call explicitly PyGC_Collect() to free all free lists. Note: PySet_ClearFreeList() did nothing.
The Windows 64 job of Azure Pipelines PR fails to build Python because it failed to fetch bzip2:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a bit of post-commit feedback on the wording of the whatsnew entry. If you think it could be worthwhile to address, I'll open a separate PR.
* Remove the following functions from the C API. Call :c:func:`PyGC_Collect` | ||
explicitly to free all free lists. | ||
(Contributed by Victor Stinner in :issue:`40428`.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the sentence "Call :c:func:PyGC_Collect
explicitly to free all free lists", "free all free lists" (although technically correct) is not especially clear without the context of how the GC works. If one reads it literally, they may wonder "why would you need to explicitly free lists that are already free?".
If my own understanding is correct, I think it might make it a bit more clear if we were to instead use "immediately deallocate all free lists". It doesn't go into detail, which wouldn't make sense here, but I think it's less ambiguous. IMO, it also reads better than "free all free lists".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, as a more minor grammar fix, the second sentence could be started with "Instead, ", as in "Instead, call :c:func:PyGC_Collect
explicitly to free all free lists." . If the above isn't worthwhile though, I don't think that would be worth a PR on its own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best would be to document PyGC_Collect()... but currently, this function is not documented in Doc/c-api/ !
"why would you need to explicitly free lists that are already free?".
Is "Call PyGC_Collect() explicitly to clear all free lists." better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to propose a PR to enhance What's New In Python 3.9. English is not my first language ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "Call PyGC_Collect() explicitly to clear all free lists." better?
Yeah, that's definitely an improvement.
Feel free to propose a PR to enhance What's New In Python 3.9. English is not my first language ;-)
Sounds good, will do. I might also look into documenting PyGC_Collect()
, but I'll likely require some feedback since the C-API isn't my area of expertise. Would you mind if I requested your review on it to make sure it's correct from a technical perspective?
Also, I think you have good English skills, especially for a non-native speaker! As a native speaker who's had to go through several college English courses though, I'm glad to help where I can with the documentation; similarly to how I'd ask you or others for help w/ the C-API. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created PR #19793 to group other C API changes related to free lists. I replace "free" with "clear" there ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vstinner Thanks for the update. I was about to work on it tomorrow otherwise, just finishing up my finals for the semester. :-)
I still plan on looking into documenting PyGC_Collect
, but I need to more closely analyze the implementation and existing docstring first to make sure I get the details right. I'll open a PR and request a review when it's ready (if that's okay).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still plan on looking into documenting PyGC_Collect, but I need to more closely analyze the implementation and existing docstring first to make sure I get the details right. I'll open a PR and request a review when it's ready (if that's okay).
Well, there is an easy way to document PyGC_Collect: it's similar to the Python gc.collect() (called without arguments), except that PyGC_Collect() does nothing if the GC is disabled.
Remove the following function from the C API:
Make these functions private, move them to the internal C API and
change their return type to void.
Call explicitly PyGC_Collect() to free all free lists.
Note: PySet_ClearFreeList() did nothing.
https://bugs.python.org/issue40428