summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2012-01-20 22:57:25 -0500
committertlatorre <tlatorre@uchicago.edu>2021-05-09 08:42:38 -0700
commit27708e4184d45338b85872fc7d23440b75e712fd (patch)
treeeda037983aae92b40909c19fe6bdaf38e5860df2
parentc1b6aad3f3e6ba7299cd352999ba1c8f82cf9367 (diff)
downloadchroma-27708e4184d45338b85872fc7d23440b75e712fd.tar.gz
chroma-27708e4184d45338b85872fc7d23440b75e712fd.tar.bz2
chroma-27708e4184d45338b85872fc7d23440b75e712fd.zip
Do not cache the individual solids. Speeds up unpickling significantly.
-rw-r--r--chroma/cache.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/chroma/cache.py b/chroma/cache.py
index 5a00df2..a22f2f8 100644
--- a/chroma/cache.py
+++ b/chroma/cache.py
@@ -10,6 +10,7 @@ process is present.
import os
import cPickle as pickle
+import copy
from chroma.log import logger
@@ -100,16 +101,17 @@ class Cache(object):
'''Save ``geometry`` in the cache with the name ``name``.'''
geo_file = self.get_geometry_filename(name)
# exclude saving the BVH
- bvh = geometry.bvh
- try:
- geometry.bvh = None
- with open(geo_file, 'wb') as output_file:
- pickle.dump(geometry.mesh.md5(), output_file,
- pickle.HIGHEST_PROTOCOL)
- pickle.dump(geometry, output_file,
- pickle.HIGHEST_PROTOCOL)
- finally:
- geometry.bvh = bvh
+ reduced_geometry = copy.copy(geometry)
+ reduced_geometry.bvh = None
+ reduced_geometry.solids = []
+ reduced_geometry.solid_rotations = []
+ reduced_geometry.solid_displacements = []
+
+ with open(geo_file, 'wb') as output_file:
+ pickle.dump(geometry.mesh.md5(), output_file,
+ pickle.HIGHEST_PROTOCOL)
+ pickle.dump(reduced_geometry, output_file,
+ pickle.HIGHEST_PROTOCOL)
def load_geometry(self, name):
'''Returns the chroma.geometry.Geometry object associated with