I've been looking at python/swift interop and from what I've been able to piece together from github,
dlopen on the users path to python. Some questions I have are:
dlopen spin up an actual Python interpreter? I always assumed it just loads a library to call into.
- Do multiple calls to
Python.import spin up multiple interpreters or simple load a library?
- How does this interface with concurrency in Swift? Will I be using separate interpreters per thread or a single global one? What are the implications here?
dlopen loads the Python runtime library of a particular version (selected via
PythonLibrary.useVersion(_:_:)), without running an actual Python interpreter.
It loads a Python module by calling
PyImport_ImportModule(_:) without creating new interpreters.
Was just reading through https://docs.python.org/2.0/api/threads.html
So if I'm interpreting this documentation correctly there is 1 interpreter and then a global lock that threads have to acquire when they want to run python.
without running an actual Python interpreter.
Does the interpreter then only run when dynamic calls are made to
PythonObjects? Does every call to a
PythonObject have to acquire the lock individually?