Skip to content

Commit

Permalink
Merge pull request #85 from mrocklin/fast-module-save
Browse files Browse the repository at this point in the history
Assume modules with __file__ attribute are not dynamic
  • Loading branch information
minrk authored May 3, 2017
2 parents 938fc0d + a99b614 commit 0be0fae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cloudpickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,14 @@ def save_module(self, obj):
"""
mod_name = obj.__name__
# If module is successfully found then it is not a dynamically created module
try:
_find_module(mod_name)
if hasattr(obj, '__file__'):
is_dynamic = False
except ImportError:
is_dynamic = True
else:
try:
_find_module(mod_name)
is_dynamic = False
except ImportError:
is_dynamic = True

self.modules.add(obj)
if is_dynamic:
Expand Down

0 comments on commit 0be0fae

Please sign in to comment.