Idea: Do not load libpython when precompiling
I maintainer di solito rispondono entro 1 giorno
@cjdoris ci sta già lavorando.
Dal 23/10/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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).
- Lingua principale
- Julia
- Stelle
- 1.1k
- Fork
- 89
- Merge medio
- 2g 15h
- PR unite (30g)
- 7
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di JuliaPy/PythonCall.jl
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
JuliaPy/PythonCall.jl#828 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
JuliaPy/PythonCall.jl#809 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Locking julia dependenciesApertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
JuliaPy/PythonCall.jl#805 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
JuliaPy/PythonCall.jl#796 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
JuliaPy/PythonCall.jl#790 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di JuliaPy/PythonCall.jl
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
EnzymeAD/ReactantServer.jl#103 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ClapeyronThermo/Clapeyron.jl#649 ·
-
Add DocStringExtensionsApertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ohno/Antique.jl#165 ·
-
`UnitLowerTriangular(transpose(M')) \ b` returns a wrong solutionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
JuliaLang/LinearAlgebra.jl#1749 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100