From 1140c853d143abc61655d8ae2ab43585ffc3c59c Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 4 Nov 2015 16:42:07 +0100 Subject: [PATCH] Try to use Protobuf CPP implementation if it is available The C++ implementation is far faster so should always be used if available. If not, we log a warning since it makes a big difference. --- cura/CuraApplication.py | 3 +++ cura_app.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 64551948dc..c194aedc61 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -134,6 +134,9 @@ class CuraApplication(QtApplication): parser.add_argument("--debug", dest="debug-mode", action="store_true", default=False, help="Enable detailed crash reports.") def run(self): + if not "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" in os.environ or os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] != "cpp": + Logger.log("w", "Using Python implementation of Protobuf, expect bad performance!") + self._i18n_catalog = i18nCatalog("cura"); i18nCatalog.setTagReplacements({ diff --git a/cura_app.py b/cura_app.py index e71fbd6515..92624be76f 100755 --- a/cura_app.py +++ b/cura_app.py @@ -4,6 +4,7 @@ # Cura is released under the terms of the AGPLv3 or higher. import sys +import os def exceptHook(type, value, traceback): import cura.CrashHandler @@ -11,6 +12,13 @@ def exceptHook(type, value, traceback): sys.excepthook = exceptHook +try: + from google.protobuf.pyext import _message +except ImportError: + pass +else: + os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp" + import cura.CuraApplication if sys.platform == "win32" and hasattr(sys, "frozen"):