We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38a9843 commit 4d5eb20Copy full SHA for 4d5eb20
src/knuth-bendix.cpp
@@ -54,10 +54,14 @@ namespace libsemigroups {
54
namespace {
55
std::string to_latin1(std::string const& u) {
56
static py::object bytes;
57
- try {
58
- bytes = py::getattr(py::globals()["__builtins__"], "bytes");
59
- } catch (py::error_already_set& e) {
60
- bytes = py::globals()["__builtins__"]["bytes"];
+ static bool first_call = true;
+ if (first_call) {
+ first_call = false;
+ try {
61
+ bytes = py::getattr(py::globals()["__builtins__"], "bytes");
62
+ } catch (py::error_already_set& e) {
63
+ bytes = py::globals()["__builtins__"]["bytes"];
64
+ }
65
}
66
return PyBytes_AS_STRING(bytes(py::str(u), "latin1").ptr());
67
0 commit comments