Idea: Do not load libpython when precompiling
維護者通常 1 天內回覆
@cjdoris 已經在處理了。
開始於 2025年10月23日。
評估
這個 Issue 還沒有評估資料。
描述
I propose that when PythonCall is being precompiled, we do not load/initialise libpython. Instead, have shims for the C functions that we use which raise an error or do something else trivial when used.
This means that we do not need to resolve a CondaPkg environment when precompiling, which will make precompilation much faster, simpler and more reliable.
This is breaking because it restricts which Python operations you are allowed to perform during __init__. I suggest that we make all of our shims return errors (clearly stating that you cannot perform this Python operation during module initialisation) except for those which return Python objects, which should return PyPtr(1) (or anything non-NULL) instead.
In particular, we should allow these operations at init:
- incref, decref, initialize, finalize and other such functions we only use internally
pyimport,pygetattr,pygetitem,pyrepr,pystr,pycall,pyhash(always return 1)- creation of python objects from nothing, bool, string, number, etc. (Py)
- GIL handling
And we'll need to disallow the following functions, which require an actual Python interpreter to return reasonable answers:
pylen,pyhasattr,pynext(PyIter_Next)pyconvert(such asPyLong_AsLongLongetc)
Concretely, we can make shim functions like this:
shim_error() =
error("You cannot perform this Python operation during module initialisation.")
shim_PyObject_IsTrue(::PyPtr) = shim_error()
shim_PyObject_Length(::PyPtr) = shim_error()
...
shim_Py_IncRef(::PyPtr) = nothing
shim_PyImport_ImportModule(::Ptr{Cchar}) = PyPtr(1)
shim_PyObject_GetAttr(::PyPtr, ::PyPtr, ::PyPtr) = PyPtr(1)
shim_PyLong_FromLongLong(::Clonglong) = PyPtr(1)
...
And then in init_pointers set the fields of POINTERS like this:
p.PyObject_IsTrue = @cfunction(PyObject_IsTrue_shim, Cint, (PyPtr,))
p.PyImport_ImportModule = @cfunction(PyImport_ImportModule_shim, PyPtr, (Ptr{Cchar},))
...
We should also initialise all the exceptions and other object pointers to PyPtr(1).
- 主要語言
- Julia
- 星號
- 1.1k
- 分支
- 89
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 7
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
JuliaPy/PythonCall.jl 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
JuliaPy/PythonCall.jl#828 · 7 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 48/100
JuliaPy/PythonCall.jl#809 · 2 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 35/100
JuliaPy/PythonCall.jl#805 · 4 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 3/5 1-2 天 新手友好度 68/100
JuliaPy/PythonCall.jl#796 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
JuliaPy/PythonCall.jl#790 ·
維護者通常 1 天內回覆
查看 JuliaPy/PythonCall.jl 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
oxfordcontrol/COSMO.jl#211 ·
-
documentation
難度 2/5 半天 新手友好度 65/100
維護者通常 6 天內回覆
-
Out-of-place JLArray/GPU problem with VectorContinuousCallback scalar-indexes (callback cache built with CPU zeros)可能已有人在做 @ChrisRackauckas-Claude 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
SciML/OrdinaryDiffEq.jl#4813 ·
維護者通常 1 天內回覆
-
ARKODE: callbacks that modify `u` throw MethodError on reinit可能已有人在做 @devmotion 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 79/100
SciML/Sundials.jl#575 ·
-
難度 1/5 1 小時以內 新手友好度 78/100
維護者通常 1 天內回覆