Idea: Do not load libpython when precompiling
Maintainer antworten meist innerhalb von 1 Tag
@cjdoris arbeitet bereits daran.
Seit 23.10.2025.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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).
- Vorherrschende Sprache
- Julia
- Sterne
- 1.1k
- Forks
- 89
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus JuliaPy/PythonCall.jl
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
JuliaPy/PythonCall.jl#828 · 7 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
JuliaPy/PythonCall.jl#809 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
JuliaPy/PythonCall.jl#805 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
JuliaPy/PythonCall.jl#796 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
JuliaPy/PythonCall.jl#790 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in JuliaPy/PythonCall.jl
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
oxfordcontrol/COSMO.jl#211 ·
-
documentation
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 6 Tagen
-
broken links in docsOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
JuliaPhysics/BeamletOptics.jl#127 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Chains resumed from `initial_state` take `num_warmup + 1` warm-up stepsEvtl. vergeben @thevolatilebit hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
TuringLang/AbstractMCMC.jl#220 ·