Idea: Do not load libpython when precompiling
Maintainer thường phản hồi trong vòng 1 ngày
@cjdoris đang làm issue này rồi.
Từ ngày 23/10/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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).
- Ngôn ngữ chính
- Julia
- Star
- 1.1k
- Fork
- 89
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaPy/PythonCall.jl
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
JuliaPy/PythonCall.jl#828 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
JuliaPy/PythonCall.jl#809 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Locking julia dependenciesĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
JuliaPy/PythonCall.jl#805 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
JuliaPy/PythonCall.jl#796 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
JuliaPy/PythonCall.jl#790 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của JuliaPy/PythonCall.jl
Issue tương tự
-
broken links in docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
JuliaPhysics/BeamletOptics.jl#127 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Chains resumed from `initial_state` take `num_warmup + 1` warm-up stepsCó thể đã có người làm @thevolatilebit đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
TuringLang/AbstractMCMC.jl#220 ·
-
found-by-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
exanauts/SparseDirectSolver.jl#92 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`inv` of a dense matrix fails for arrays whose `parent` is not an array of the same kindCó thể đã có người làm @devmotion đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
JuliaLang/LinearAlgebra.jl#1740 ·
Maintainer thường phản hồi trong vòng 2 ngày