Skip to content

Commit ee2188d

Browse files
author
Justin Black
committed
Adds wraps decorator to profile, rev roll to 0.53.0
1 parent 0b6e2bf commit ee2188d

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ MANIFEST
88

99
# Ignore mprof generated files
1010
mprofile_*.dat
11+
12+
# virtual environment
13+
venv/

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ test:
1515
$(PYTHON) test/test_memory_usage.py
1616
$(PYTHON) test/test_precision_import.py
1717
$(PYTHON) test/test_exception.py
18+
19+
develop:
20+
pip install -e .

memory_profiler.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
# .. we'll use this to pass it to the child script ..
44
_CLEAN_GLOBALS = globals().copy()
55

6-
__version__ = '0.50.0'
6+
__version__ = '0.53.0'
77

88
_CMD_USAGE = "python -m memory_profiler script_file.py"
99

10-
import time
11-
import sys
10+
from functools import wraps
11+
import inspect
12+
import linecache
13+
import logging
1214
import os
1315
import pdb
14-
import warnings
15-
import linecache
16-
import inspect
1716
import subprocess
18-
import logging
17+
import sys
18+
import time
1919
import traceback
20+
import warnings
21+
2022
if sys.platform == "win32":
2123
# any value except signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT
2224
# can be used to kill a process unconditionally in Windows
@@ -1067,6 +1069,7 @@ def profile(func=None, stream=None, precision=1, backend='psutil'):
10671069
if not tracemalloc.is_tracing():
10681070
tracemalloc.start()
10691071
if func is not None:
1072+
@wraps(func)
10701073
def wrapper(*args, **kwargs):
10711074
prof = LineProfiler(backend=backend)
10721075
val = prof(func)(*args, **kwargs)

0 commit comments

Comments
 (0)