Skip to content

Commit 5cd5d83

Browse files
Added caching
1 parent 324087a commit 5cd5d83

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ifcjson/ifc2json4.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
import os
2121
import uuid
22+
import functools
2223
import ifcopenshell
2324
import ifcopenshell.guid as guid
2425
import ifcjson.common as common
2526

2627
class IFC2JSON4:
28+
maxCache=2048
2729
def __init__(self, ifcFilePath):
2830
self.ifcFilePath = ifcFilePath
2931
self.ifcModel = ifcopenshell.open(ifcFilePath)
@@ -46,6 +48,7 @@ def spf2Json(self):
4648
jsonObjects.append(self.id_objects[key])
4749
return jsonObjects
4850

51+
@functools.lru_cache(maxsize=maxCache)
4952
def entityToDict(self, entity):
5053
attr_dict = entity.__dict__
5154

@@ -147,6 +150,7 @@ def entityToDict(self, entity):
147150
d[attrKey] = attr_dict[attr]
148151
return d
149152

153+
@functools.lru_cache(maxsize=maxCache)
150154
def getEntityValue(self, value):
151155
if value == None:
152156
jsonValue = None

0 commit comments

Comments
 (0)