Skip to content

Commit

Permalink
Release the gil when computing signatures or log-signatures. (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
inakleinbottle authored Dec 13, 2023
1 parent f734703 commit 7ffb57a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions roughpy/src/streams/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static PyObject* signature(PyObject* self, PyObject* args, PyObject* kwargs)

algebra::FreeTensor result;
try {
py::gil_scoped_release gil;
if (sigargs.interval) {
if (sigargs.resolution) {
result = stream->m_data.signature(
Expand Down Expand Up @@ -330,25 +331,31 @@ static PyObject* log_signature(PyObject* self, PyObject* args, PyObject* kwargs)
}

algebra::Lie result;
if (sigargs.interval) {
if (sigargs.resolution) {
result = stream->m_data.log_signature(
try {
py::gil_scoped_release gil;
if (sigargs.interval) {
if (sigargs.resolution) {
result = stream->m_data.log_signature(
*sigargs.interval,
*sigargs.resolution,
*sigargs.ctx
);
} else {
result = stream->m_data.log_signature(
);
} else {
result = stream->m_data.log_signature(
*sigargs.interval,
*sigargs.ctx
);
}
} else {
if (sigargs.resolution) {
result = stream->m_data.log_signature(*sigargs.resolution, *sigargs.ctx);
);
}
} else {
result = stream->m_data.log_signature(*sigargs.ctx);
if (sigargs.resolution) {
result = stream->m_data.log_signature(*sigargs.resolution, *sigargs.ctx);
} else {
result = stream->m_data.log_signature(*sigargs.ctx);
}
}
} catch (std::exception &err) {
PyErr_SetString(PyExc_RuntimeError, err.what());
return nullptr;
}

return py::cast(result).release().ptr();
Expand Down

0 comments on commit 7ffb57a

Please sign in to comment.