diff --git a/import_profiler.py b/import_profiler.py index 39b4819..3f869cd 100644 --- a/import_profiler.py +++ b/import_profiler.py @@ -56,14 +56,14 @@ def compute_intime(parent, full_stack, elapsed, ordered_visited, visited, depth= class ImportProfilerContext(object): def __init__(self): - self._original_importer = __builtins__["__import__"] + self._original_importer = getattr(__builtins__, "__import__") self._import_stack = ImportStack() def enable(self): - __builtins__["__import__"] = self._profiled_import + setattr(__builtins__, "__import__", self._profiled_import) def disable(self): - __builtins__["__import__"] = self._original_importer + setattr(__builtins__, "__import__", self._original_importer) def print_info(self, threshold=1.): """ Print profiler results. @@ -116,7 +116,7 @@ def __exit__(self, *a, **kw): self.disable() def _profiled_import(self, name, globals=None, locals=None, fromlist=None, - level=-1, *a, **kw): + level=0, *a, **kw): if globals is None: context_name = None else: diff --git a/setup.py b/setup.py index 6796949..f1b6bb9 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,13 @@ if __name__ == "__main__": setup( - name="import_profiler", - version="0.0.4.dev0", - author="David Cournapeau", + name="import_profiler3", + version="0.0.1", + author="David Cournapeau, Prashant Sengar", author_email="cournape@gmail.com", license="MIT", install_requires=["attrs >= 17.1.0", "tabulate >= 0.7.5"], - description="Import profiler to find bottlenecks in import times.", + description="Import profiler to find bottlenecks in import times - supports Python 3.", long_description=DESCRIPTION, py_modules=["import_profiler"], )