You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The speed-up for us seems to be coming from the fact that pickling modules takes a long time:
In [25]: %timeit cloudpickle.dumps(numpy, -1)
100 loops, best of 3: 3.03 ms per loop
It looks like _find_module() will use imp.find_module() which traverses sys.path to look for things that look like numpy. In our environment, sys.path tends to be long and our filesystems tend to be slow, hence the 3.03 ms.
defsave_module(self, obj):
""" Save a module as an import """mod_name=obj.__name__# If module is successfully found then it is not a dynamically created moduletry:
_find_module(mod_name) # EXPENSIVE!!!!!is_dynamic=FalseexceptImportError:
is_dynamic=Trueself.modules.add(obj)
ifis_dynamic:
self.save_reduce(dynamic_subimport, (obj.__name__, vars(obj)), obj=obj)
else:
self.save_reduce(subimport, (obj.__name__,), obj=obj)
dispatch[types.ModuleType] =save_module
So it looks like cloudpickle is trying to allow for "dynamically created modules". If it didn't try to be this flexible, then the entire function should just be
Activity
Assume modules with __file__ attribute are not dynamic
Assume modules with __file__ attribute are not dynamic