Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3 #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions import_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
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"],
)