all datetime columns changed to timestamp, change from json to faster orjson
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import json
|
||||
import orjson
|
||||
|
||||
|
||||
class ToolBox:
|
||||
@ -22,14 +22,14 @@ class ToolBox:
|
||||
"""
|
||||
if not self.drawings.get(tag):
|
||||
return
|
||||
self.run_script(f'if ({self.id}.toolBox) {self.id}.toolBox.loadDrawings({json.dumps(self.drawings[tag])})')
|
||||
self.run_script(f'if ({self.id}.toolBox) {self.id}.toolBox.loadDrawings({orjson.dumps(self.drawings[tag])})')
|
||||
|
||||
def import_drawings(self, file_path):
|
||||
"""
|
||||
Imports a list of drawings stored at the given file path.
|
||||
"""
|
||||
with open(file_path, 'r') as f:
|
||||
json_data = json.load(f)
|
||||
json_data = orjson.load(f)
|
||||
self.drawings = json_data
|
||||
|
||||
def export_drawings(self, file_path):
|
||||
@ -37,9 +37,9 @@ class ToolBox:
|
||||
Exports the current list of drawings to the given file path.
|
||||
"""
|
||||
with open(file_path, 'w+') as f:
|
||||
json.dump(self.drawings, f, indent=4)
|
||||
orjson.dump(self.drawings, f, indent=4)
|
||||
|
||||
def _save_drawings(self, drawings):
|
||||
if not self._save_under:
|
||||
return
|
||||
self.drawings[self._save_under.value] = json.loads(drawings)
|
||||
self.drawings[self._save_under.value] = orjson.loads(drawings)
|
||||
|
||||
Reference in New Issue
Block a user