12 namespace py = pybind11;
19 static constexpr
auto PyTab =
" ";
31 void write(std::string Str);
63 template <
typename T, std::enable_if_t<
64 std::is_base_of_v<py::object, T>,
int> = 0
94 this->Object = std::make_unique<T>(
Object);
115 py::gil_scoped_acquire acquire;
116 Object = std::make_unique<T>();
127 template <
typename... ArgTs>
131 return (*
Object)(std::forward<ArgTs>(Args)...);
142 py::gil_scoped_acquire acquire;
Initialize Python interpreter and directly release the GIL after construction.
PyGilReleasedInterpreter()
py::module_ Module_sys
Handle to the Python sys module.
py::gil_scoped_release GILRelease
Release which releases the GIL at construction.
void PrintDebugInfo()
Writes information on the Python interpreter configuration to DynExp's log.
PyStdoutLoggerWrapper Logger
Wrapper to forward DynExp's event log to Python.
py::scoped_interpreter Interpreter
Python interpreter.
Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is...
PyObject(const T &Object)
Copy-constructs a PyObject from Object.
auto & Get() const noexcept
Returns the wrapped pybind11::object.
std::unique_ptr< T > Object
Object derived from pybind11::object owned by this PyObject instance.
PyObject & operator=(const T &Object)
Locks the GIL, removes the owned object and copy-assigns from Object.
~PyObject()
Removes the owned pybind11::object after locking the GIL.
PyObject()
Constructs an empty PyObject.
void Reset()
Removes the owned pybind11::object after locking the GIL.
void Remove()
Removes the owned pybind11::object after locking the GIL.
py::object operator()(ArgTs &&...Args) const
Calls the wrapped object if it is not nullptr and if the wrapped object is not pybind11::none.
auto & Get() noexcept
Returns the wrapped pybind11::object. noexcept
Forwards Python's stdout to Util::EventLogger instance defined in Util::EventLog().
void write(std::string Str)
Formats the string passed to the function and writes it to the event log.
void flush()
Required, but does nothing.
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
static constexpr auto PyTab
Character sequence to indent a Python instruction by one level.
Accumulates include statements to provide a precompiled header.