-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
Isolate Stdlib Extension Modules #103092
Comments
Ideally we'll get most of this done for 3.12. FWIW, there isn't enough time if it's just me, so consider this a call out to whoever can help. 😄 Feel free to adjust the TODO list and (hidden) "analysis" table above. Also feel free to reach out to any others that might be interested in pitching in here. Thanks!!! @erlend-aasland, @corona10, @kumaraditya303, etc. |
@terryjreedy (for _tkinter) |
I've got WIP branches for datetime, io, pickle, collections, and ssl. The three former are up as draft PRs. (FYI, I have quite a bit of CPython time scheduled for next week.) |
Regarding the freelists in |
Elementtree was isolated/ported in gh-92123. |
|
Thanks for the updates! |
@serhiy-storchaka for _tkinter. I have nothing to do with it. |
AFAICS, |
I will try to find which modules that I can support for this issue :) |
Feel free to pick up any of my draft PRs! :) |
I tried submitting some PRs(Port _datatime module, Convert _pickle module to use heap types) for multi-phase initialization last year (delayed due to PEP 687 not being accepted at that time). |
Looks like you can reopen your PRs :) |
Sure you can! I started doing some work on |
I volunteer to review the PRs as I have been doing, and leave |
@erlend-aasland I'd like |
Converting static types to heap types is not the blocker issue for the datetime. The problem of datetime is its C API. It reminds me the problem of the AST C API. We tried different things but we had multiple crashes. At the end, I moved AST types to the PyInterpreterState, they are initialized at the first access. This way, from any code path, you always meet the same types. Before, depending on how types were created, you might meet different types and so PyAST_Check() returned false which was very surprising. I can help you if you open an issue. But please, first, move definition of these types to PyInterpreterState (put |
Maybe already known, but reloading any module (e.g. import sys
from _decimal import Decimal as D1
del sys.modules['_decimal']
from _decimal import Decimal as D2
print(a := D1(1), b := D1(1), a == b, a is b) # load
print(c := D2(1), d := D2(1), c == d, c is d) # reload
print(a == c)
1 1 True False
1 1 True False
True
1 1 True False
1 1 True False
False # a and c have different module states Indeed, |
What do you mean by unsafe? If something's unsafe at the C level (e.g. undefined behaviour, crashes), that's a bug. This behaviour is known; see https://docs.python.org/3/howto/isolating-extensions.html#surprising-edge-cases and the warning in https://docs.python.org/3/library/sys.html#sys.modules |
Thanks. I suspect EDIT: The |
I've opened a |
@Yhg1s, could we get an exception for 3.13 like we got for 3.12, regarding porting stdlib extensions to multi-phase init? You let us land those changes up to beta 2. This time around there are only two modules left to be done, and the PRs for both are close enough that I expect they could be wrapped up before beta 2 (end of May). |
From #118357 (comment):
I said at #103092 (comment) in this thread:
You replied:
Then, I opened the issue #117398. I think we are aware of #113601, whose original issue was raised a year ago and you said there (#100911 (comment)):
We know well that the porting resolves existing different issues derived from static types and single-phase init. My volunteer is following the generic approach that seems to be supported by active core devs, especially by you. Also, the recent crash case you reported at #116467 on @kumaraditya303 has not been in good health, right? And @erlend-aasland appears to be not working individually on this project, and to be exhausted: #110415 (comment). As to
Again, how do you think of the delay? Maybe isolated |
Please open a dedicated issue for the datetime crash. |
I don't think that it's a good idea. Regressions are complex to debug/fix, and it's better to continue the work in Python 3.14 and learn how to work around Python 3.13 limited isolation. |
Which modules are we talking about? You referenced this from a _datetime change that didn't seem to actually switch to multi-phase init. |
Opened #118608, whose title is taken from the |
Oh, Python 3.12 is also affected. We cannot isolate datetime in 3.12 to fix the issue. We will need a different fix for 3.12. So 3.13 can use the same fix. |
Unfortunately, |
datetime and ctypes. Those are the only two left from the list at the top of this issue. |
…eters (python#113434) Enable imports of _elementtree module in sub-interpreters
) Test the following features for _ctypes types: - disallow instantiation - inheritance (MRO) - immutability - type name The following _ctypes types are tested: - Array - CField - COMError - PyCArrayType - PyCFuncPtrType - PyCPointerType - PyCSimpleType - PyCStructType - Structure - Union - UnionType - _CFuncPtr - _Pointer - _SimpleCData Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
…onGH-113620) Co-authored-by: Erlend E. Aasland <erlend@python.org>
See PEP 687.
Currently most stdlib extension have been ported to multi-phase init. There are still a number of them to be ported, almost entirely non-builtin modules. Also, some that have already been ported still have global state that needs to be fixed.
(This is part of the effort to finish isolating multiple interpreters from each other. See gh-100227.)
High-Level Info
How to isolate modules: https://docs.python.org/3/howto/isolating-extensions.html (AKA PEP 630).
The full list of modules that need porting can be found with:
...
The full list of remaining (unsupported) global variables is:
A full analysis of the modules may be found at the bottom of this post.
(other info)
Previous Work
Related Links
TODO
Here is the list of modules that need attention, in a rough, best-effort priority order. Additional details (e.g. if there is an issue and/or PR) is found in the analysis table at the bottom.
_io
extension module #101819_decimal
extension module #106078The above does not include test modules. They don't need to be ported/isolated (except for a few which already have been).
Modules Analysis
test/example modules
These can be ported/isolated but don't have to be. They are the lowest priority.
Linked PRs
_pickle
#102982_decimal
#103381_asyncio
freelist to module state #104196pyexpat
#104506_elementtree
#104561_ssl
#104725_elementtree
module importable in sub-interpreters #113434pyexpat
module importable in sub-interpreters #113555_ctypes
metatypes to heap types #113620_ctypes
data types to heap types #113630_ctypes
type hierarchy and features #113727_ctypes
data types to heap types (alt) #113774_ctypes.c
static types are accessed via global state #113857The text was updated successfully, but these errors were encountered: