Linux business57.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
LiteSpeed
Server IP : 199.188.201.191 & Your IP : 3.15.226.5
Domains :
Cant Read [ /etc/named.conf ]
User : derozboy
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
python34 /
lib64 /
python3.4 /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
asyncio
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
collections
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
concurrent
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
config-3.4m
[ DIR ]
drwxr-xr-x
2024-05-21 08:57
ctypes
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
curses
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
dbm
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
distutils
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
email
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
encodings
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
ensurepip
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
html
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
http
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
idlelib
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
importlib
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
json
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
lib-dynload
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
lib2to3
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
logging
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
multiprocessing
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
plat-linux
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
pydoc_data
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
site-packages
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
sqlite3
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
test
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
unittest
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
urllib
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
venv
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
wsgiref
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
xml
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
xmlrpc
[ DIR ]
drwxr-xr-x
2024-05-21 08:48
__future__.py
4.48
KB
-rw-r--r--
2024-04-17 17:10
__phello__.foo.py
64
B
-rw-r--r--
2024-04-17 17:10
_bootlocale.py
1.27
KB
-rw-r--r--
2024-04-17 17:09
_collections_abc.py
19.43
KB
-rw-r--r--
2024-04-17 17:09
_compat_pickle.py
8.12
KB
-rw-r--r--
2024-04-17 17:10
_dummy_thread.py
4.76
KB
-rw-r--r--
2024-04-17 17:10
_markupbase.py
14.26
KB
-rw-r--r--
2024-04-17 17:09
_osx_support.py
18.65
KB
-rw-r--r--
2024-04-17 17:10
_pyio.py
72.16
KB
-rw-r--r--
2024-04-17 17:09
_sitebuiltins.py
3.04
KB
-rw-r--r--
2024-04-17 17:09
_strptime.py
21.54
KB
-rw-r--r--
2024-04-17 17:10
_sysconfigdata.py
28.05
KB
-rw-r--r--
2024-04-17 17:10
_threading_local.py
7.24
KB
-rw-r--r--
2024-04-17 17:09
_weakrefset.py
5.57
KB
-rw-r--r--
2024-04-17 17:09
abc.py
8.42
KB
-rw-r--r--
2024-04-17 17:09
aifc.py
30.84
KB
-rw-r--r--
2024-04-17 17:10
antigravity.py
475
B
-rw-r--r--
2024-04-17 17:09
argparse.py
87.92
KB
-rw-r--r--
2024-04-17 17:10
ast.py
11.75
KB
-rw-r--r--
2024-04-17 17:10
asynchat.py
11.55
KB
-rw-r--r--
2024-04-17 17:10
asyncore.py
20.51
KB
-rw-r--r--
2024-04-17 17:10
base64.py
19.71
KB
-rwxr-xr-x
2024-04-17 17:09
bdb.py
22.81
KB
-rw-r--r--
2024-04-17 17:10
binhex.py
13.6
KB
-rw-r--r--
2024-04-17 17:09
bisect.py
2.53
KB
-rw-r--r--
2024-04-17 17:09
bz2.py
18.42
KB
-rw-r--r--
2024-04-17 17:10
cProfile.py
5.2
KB
-rwxr-xr-x
2024-04-17 17:09
calendar.py
22.4
KB
-rw-r--r--
2024-04-17 17:10
cgi.py
35.1
KB
-rwxr-xr-x
2024-04-17 17:10
cgitb.py
11.76
KB
-rw-r--r--
2024-04-17 17:10
chunk.py
5.3
KB
-rw-r--r--
2024-04-17 17:09
cmd.py
14.51
KB
-rw-r--r--
2024-04-17 17:09
code.py
9.8
KB
-rw-r--r--
2024-04-17 17:09
codecs.py
35.07
KB
-rw-r--r--
2024-04-17 17:09
codeop.py
5.85
KB
-rw-r--r--
2024-04-17 17:09
colorsys.py
3.97
KB
-rw-r--r--
2024-04-17 17:09
compileall.py
9.39
KB
-rw-r--r--
2024-04-17 17:09
configparser.py
48.53
KB
-rw-r--r--
2024-04-17 17:09
contextlib.py
11.37
KB
-rw-r--r--
2024-04-17 17:09
copy.py
8.79
KB
-rw-r--r--
2024-04-17 17:09
copyreg.py
6.67
KB
-rw-r--r--
2024-04-17 17:10
crypt.py
1.83
KB
-rw-r--r--
2024-04-17 17:09
csv.py
15.81
KB
-rw-r--r--
2024-04-17 17:09
datetime.py
74.03
KB
-rw-r--r--
2024-04-17 17:10
decimal.py
223.33
KB
-rw-r--r--
2024-04-17 17:10
difflib.py
79.77
KB
-rw-r--r--
2024-04-17 17:09
dis.py
16.76
KB
-rw-r--r--
2024-04-17 17:09
doctest.py
102.04
KB
-rw-r--r--
2024-04-17 17:09
dummy_threading.py
2.75
KB
-rw-r--r--
2024-04-17 17:09
enum.py
21.03
KB
-rw-r--r--
2024-04-17 17:09
filecmp.py
9.6
KB
-rw-r--r--
2024-04-17 17:09
fileinput.py
14.52
KB
-rw-r--r--
2024-04-17 17:09
fnmatch.py
3.09
KB
-rw-r--r--
2024-04-17 17:09
formatter.py
14.82
KB
-rw-r--r--
2024-04-17 17:09
fractions.py
22.66
KB
-rw-r--r--
2024-04-17 17:09
ftplib.py
37.63
KB
-rw-r--r--
2024-04-17 17:09
functools.py
27.84
KB
-rw-r--r--
2024-04-17 17:10
genericpath.py
3.79
KB
-rw-r--r--
2024-04-17 17:10
getopt.py
7.31
KB
-rw-r--r--
2024-04-17 17:10
getpass.py
5.93
KB
-rw-r--r--
2024-04-17 17:09
gettext.py
20.28
KB
-rw-r--r--
2024-04-17 17:10
glob.py
3.38
KB
-rw-r--r--
2024-04-17 17:09
gzip.py
23.74
KB
-rw-r--r--
2024-04-17 17:10
hashlib.py
9.62
KB
-rw-r--r--
2024-04-17 17:10
heapq.py
17.58
KB
-rw-r--r--
2024-04-17 17:09
hmac.py
4.94
KB
-rw-r--r--
2024-04-17 17:09
imaplib.py
49.09
KB
-rw-r--r--
2024-04-17 17:10
imghdr.py
3.45
KB
-rw-r--r--
2024-04-17 17:10
imp.py
9.75
KB
-rw-r--r--
2024-04-17 17:09
inspect.py
102.19
KB
-rw-r--r--
2024-04-17 17:10
io.py
3.32
KB
-rw-r--r--
2024-04-17 17:09
ipaddress.py
69.92
KB
-rw-r--r--
2024-04-17 17:10
keyword.py
2.17
KB
-rwxr-xr-x
2024-04-17 17:10
linecache.py
3.86
KB
-rw-r--r--
2024-04-17 17:09
locale.py
72.78
KB
-rw-r--r--
2024-04-17 17:10
lzma.py
18.92
KB
-rw-r--r--
2024-04-17 17:10
macpath.py
5.49
KB
-rw-r--r--
2024-04-17 17:09
macurl2path.py
2.67
KB
-rw-r--r--
2024-04-17 17:09
mailbox.py
76.54
KB
-rw-r--r--
2024-04-17 17:10
mailcap.py
7.26
KB
-rw-r--r--
2024-04-17 17:09
mimetypes.py
20.29
KB
-rw-r--r--
2024-04-17 17:10
modulefinder.py
22.87
KB
-rw-r--r--
2024-04-17 17:09
netrc.py
5.61
KB
-rw-r--r--
2024-04-17 17:09
nntplib.py
42.07
KB
-rw-r--r--
2024-04-17 17:09
ntpath.py
20
KB
-rw-r--r--
2024-04-17 17:09
nturl2path.py
2.39
KB
-rw-r--r--
2024-04-17 17:10
numbers.py
10
KB
-rw-r--r--
2024-04-17 17:10
opcode.py
5.31
KB
-rw-r--r--
2024-04-17 17:10
operator.py
8.98
KB
-rw-r--r--
2024-04-17 17:10
optparse.py
58.93
KB
-rw-r--r--
2024-04-17 17:10
os.py
33.09
KB
-rw-r--r--
2024-04-17 17:09
pathlib.py
41.47
KB
-rw-r--r--
2024-04-17 17:10
pdb.py
59.56
KB
-rwxr-xr-x
2024-04-17 17:09
pickle.py
54.68
KB
-rw-r--r--
2024-04-17 17:09
pickletools.py
89.61
KB
-rw-r--r--
2024-04-17 17:09
pipes.py
8.71
KB
-rw-r--r--
2024-04-17 17:10
pkgutil.py
20.72
KB
-rw-r--r--
2024-04-17 17:09
platform.py
45.67
KB
-rwxr-xr-x
2024-04-17 17:09
plistlib.py
31.05
KB
-rw-r--r--
2024-04-17 17:09
poplib.py
13.98
KB
-rw-r--r--
2024-04-17 17:09
posixpath.py
13.13
KB
-rw-r--r--
2024-04-17 17:09
pprint.py
14.57
KB
-rw-r--r--
2024-04-17 17:09
profile.py
21.52
KB
-rwxr-xr-x
2024-04-17 17:09
pstats.py
25.7
KB
-rw-r--r--
2024-04-17 17:09
pty.py
4.65
KB
-rw-r--r--
2024-04-17 17:09
py_compile.py
6.94
KB
-rw-r--r--
2024-04-17 17:10
pyclbr.py
13.2
KB
-rw-r--r--
2024-04-17 17:09
pydoc.py
100.6
KB
-rwxr-xr-x
2024-04-17 17:09
queue.py
8.63
KB
-rw-r--r--
2024-04-17 17:10
quopri.py
7.09
KB
-rwxr-xr-x
2024-04-17 17:10
random.py
25.47
KB
-rw-r--r--
2024-04-17 17:09
re.py
15.24
KB
-rw-r--r--
2024-04-17 17:09
reprlib.py
4.99
KB
-rw-r--r--
2024-04-17 17:09
rlcompleter.py
5.93
KB
-rw-r--r--
2024-04-17 17:10
runpy.py
10.56
KB
-rw-r--r--
2024-04-17 17:09
sched.py
6.21
KB
-rw-r--r--
2024-04-17 17:10
selectors.py
16.7
KB
-rw-r--r--
2024-04-17 17:09
shelve.py
8.33
KB
-rw-r--r--
2024-04-17 17:10
shlex.py
11.28
KB
-rw-r--r--
2024-04-17 17:10
shutil.py
38.97
KB
-rw-r--r--
2024-04-17 17:10
site.py
21.05
KB
-rw-r--r--
2024-04-17 17:10
smtpd.py
29.29
KB
-rwxr-xr-x
2024-04-17 17:09
smtplib.py
38.06
KB
-rwxr-xr-x
2024-04-17 17:09
sndhdr.py
6.11
KB
-rw-r--r--
2024-04-17 17:10
socket.py
18.62
KB
-rw-r--r--
2024-04-17 17:10
socketserver.py
23.8
KB
-rw-r--r--
2024-04-17 17:10
sre_compile.py
19.44
KB
-rw-r--r--
2024-04-17 17:09
sre_constants.py
7.1
KB
-rw-r--r--
2024-04-17 17:09
sre_parse.py
30.69
KB
-rw-r--r--
2024-04-17 17:09
ssl.py
33.93
KB
-rw-r--r--
2024-04-17 17:10
stat.py
4.3
KB
-rw-r--r--
2024-04-17 17:10
statistics.py
19.1
KB
-rw-r--r--
2024-04-17 17:09
string.py
11.18
KB
-rw-r--r--
2024-04-17 17:10
stringprep.py
12.61
KB
-rw-r--r--
2024-04-17 17:09
struct.py
257
B
-rw-r--r--
2024-04-17 17:09
subprocess.py
63.04
KB
-rw-r--r--
2024-04-17 17:09
sunau.py
17.67
KB
-rw-r--r--
2024-04-17 17:09
symbol.py
2
KB
-rwxr-xr-x
2024-04-17 17:09
symtable.py
7.23
KB
-rw-r--r--
2024-04-17 17:10
sysconfig.py
24.05
KB
-rw-r--r--
2024-04-17 17:10
tabnanny.py
11.14
KB
-rwxr-xr-x
2024-04-17 17:10
tarfile.py
89.41
KB
-rwxr-xr-x
2024-04-17 17:09
telnetlib.py
22.53
KB
-rw-r--r--
2024-04-17 17:09
tempfile.py
22
KB
-rw-r--r--
2024-04-17 17:09
textwrap.py
18.83
KB
-rw-r--r--
2024-04-17 17:09
this.py
1003
B
-rw-r--r--
2024-04-17 17:09
threading.py
47.66
KB
-rw-r--r--
2024-04-17 17:10
timeit.py
11.69
KB
-rwxr-xr-x
2024-04-17 17:09
token.py
2.96
KB
-rw-r--r--
2024-04-17 17:09
tokenize.py
25
KB
-rw-r--r--
2024-04-17 17:10
trace.py
30.75
KB
-rwxr-xr-x
2024-04-17 17:09
traceback.py
10.91
KB
-rw-r--r--
2024-04-17 17:10
tracemalloc.py
15.28
KB
-rw-r--r--
2024-04-17 17:10
tty.py
879
B
-rw-r--r--
2024-04-17 17:09
types.py
5.28
KB
-rw-r--r--
2024-04-17 17:09
uu.py
6.61
KB
-rwxr-xr-x
2024-04-17 17:09
uuid.py
23.17
KB
-rw-r--r--
2024-04-17 17:09
warnings.py
13.97
KB
-rw-r--r--
2024-04-17 17:09
wave.py
17.27
KB
-rw-r--r--
2024-04-17 17:09
weakref.py
18.93
KB
-rw-r--r--
2024-04-17 17:10
webbrowser.py
20.93
KB
-rwxr-xr-x
2024-04-17 17:10
xdrlib.py
5.77
KB
-rw-r--r--
2024-04-17 17:10
zipfile.py
66.94
KB
-rw-r--r--
2024-04-17 17:10
Save
Rename
from collections import Sequence, Iterable from functools import total_ordering import fnmatch import linecache import os.path import pickle # Import types and functions implemented in C from _tracemalloc import * from _tracemalloc import _get_object_traceback, _get_traces def _format_size(size, sign): for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'): if abs(size) < 100 and unit != 'B': # 3 digits (xx.x UNIT) if sign: return "%+.1f %s" % (size, unit) else: return "%.1f %s" % (size, unit) if abs(size) < 10 * 1024 or unit == 'TiB': # 4 or 5 digits (xxxx UNIT) if sign: return "%+.0f %s" % (size, unit) else: return "%.0f %s" % (size, unit) size /= 1024 class Statistic: """ Statistic difference on memory allocations between two Snapshot instance. """ __slots__ = ('traceback', 'size', 'count') def __init__(self, traceback, size, count): self.traceback = traceback self.size = size self.count = count def __hash__(self): return hash((self.traceback, self.size, self.count)) def __eq__(self, other): return (self.traceback == other.traceback and self.size == other.size and self.count == other.count) def __str__(self): text = ("%s: size=%s, count=%i" % (self.traceback, _format_size(self.size, False), self.count)) if self.count: average = self.size / self.count text += ", average=%s" % _format_size(average, False) return text def __repr__(self): return ('<Statistic traceback=%r size=%i count=%i>' % (self.traceback, self.size, self.count)) def _sort_key(self): return (self.size, self.count, self.traceback) class StatisticDiff: """ Statistic difference on memory allocations between an old and a new Snapshot instance. """ __slots__ = ('traceback', 'size', 'size_diff', 'count', 'count_diff') def __init__(self, traceback, size, size_diff, count, count_diff): self.traceback = traceback self.size = size self.size_diff = size_diff self.count = count self.count_diff = count_diff def __hash__(self): return hash((self.traceback, self.size, self.size_diff, self.count, self.count_diff)) def __eq__(self, other): return (self.traceback == other.traceback and self.size == other.size and self.size_diff == other.size_diff and self.count == other.count and self.count_diff == other.count_diff) def __str__(self): text = ("%s: size=%s (%s), count=%i (%+i)" % (self.traceback, _format_size(self.size, False), _format_size(self.size_diff, True), self.count, self.count_diff)) if self.count: average = self.size / self.count text += ", average=%s" % _format_size(average, False) return text def __repr__(self): return ('<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>' % (self.traceback, self.size, self.size_diff, self.count, self.count_diff)) def _sort_key(self): return (abs(self.size_diff), self.size, abs(self.count_diff), self.count, self.traceback) def _compare_grouped_stats(old_group, new_group): statistics = [] for traceback, stat in new_group.items(): previous = old_group.pop(traceback, None) if previous is not None: stat = StatisticDiff(traceback, stat.size, stat.size - previous.size, stat.count, stat.count - previous.count) else: stat = StatisticDiff(traceback, stat.size, stat.size, stat.count, stat.count) statistics.append(stat) for traceback, stat in old_group.items(): stat = StatisticDiff(traceback, 0, -stat.size, 0, -stat.count) statistics.append(stat) return statistics @total_ordering class Frame: """ Frame of a traceback. """ __slots__ = ("_frame",) def __init__(self, frame): # frame is a tuple: (filename: str, lineno: int) self._frame = frame @property def filename(self): return self._frame[0] @property def lineno(self): return self._frame[1] def __eq__(self, other): return (self._frame == other._frame) def __lt__(self, other): return (self._frame < other._frame) def __hash__(self): return hash(self._frame) def __str__(self): return "%s:%s" % (self.filename, self.lineno) def __repr__(self): return "<Frame filename=%r lineno=%r>" % (self.filename, self.lineno) @total_ordering class Traceback(Sequence): """ Sequence of Frame instances sorted from the most recent frame to the oldest frame. """ __slots__ = ("_frames",) def __init__(self, frames): Sequence.__init__(self) # frames is a tuple of frame tuples: see Frame constructor for the # format of a frame tuple self._frames = frames def __len__(self): return len(self._frames) def __getitem__(self, index): if isinstance(index, slice): return tuple(Frame(trace) for trace in self._frames[index]) else: return Frame(self._frames[index]) def __contains__(self, frame): return frame._frame in self._frames def __hash__(self): return hash(self._frames) def __eq__(self, other): return (self._frames == other._frames) def __lt__(self, other): return (self._frames < other._frames) def __str__(self): return str(self[0]) def __repr__(self): return "<Traceback %r>" % (tuple(self),) def format(self, limit=None): lines = [] if limit is not None and limit < 0: return lines for frame in self[:limit]: lines.append(' File "%s", line %s' % (frame.filename, frame.lineno)) line = linecache.getline(frame.filename, frame.lineno).strip() if line: lines.append(' %s' % line) return lines def get_object_traceback(obj): """ Get the traceback where the Python object *obj* was allocated. Return a Traceback instance. Return None if the tracemalloc module is not tracing memory allocations or did not trace the allocation of the object. """ frames = _get_object_traceback(obj) if frames is not None: return Traceback(frames) else: return None class Trace: """ Trace of a memory block. """ __slots__ = ("_trace",) def __init__(self, trace): # trace is a tuple: (size, traceback), see Traceback constructor # for the format of the traceback tuple self._trace = trace @property def size(self): return self._trace[0] @property def traceback(self): return Traceback(self._trace[1]) def __eq__(self, other): return (self._trace == other._trace) def __hash__(self): return hash(self._trace) def __str__(self): return "%s: %s" % (self.traceback, _format_size(self.size, False)) def __repr__(self): return ("<Trace size=%s, traceback=%r>" % (_format_size(self.size, False), self.traceback)) class _Traces(Sequence): def __init__(self, traces): Sequence.__init__(self) # traces is a tuple of trace tuples: see Trace constructor self._traces = traces def __len__(self): return len(self._traces) def __getitem__(self, index): if isinstance(index, slice): return tuple(Trace(trace) for trace in self._traces[index]) else: return Trace(self._traces[index]) def __contains__(self, trace): return trace._trace in self._traces def __eq__(self, other): return (self._traces == other._traces) def __repr__(self): return "<Traces len=%s>" % len(self) def _normalize_filename(filename): filename = os.path.normcase(filename) if filename.endswith(('.pyc', '.pyo')): filename = filename[:-1] return filename class Filter: def __init__(self, inclusive, filename_pattern, lineno=None, all_frames=False): self.inclusive = inclusive self._filename_pattern = _normalize_filename(filename_pattern) self.lineno = lineno self.all_frames = all_frames @property def filename_pattern(self): return self._filename_pattern def __match_frame(self, filename, lineno): filename = _normalize_filename(filename) if not fnmatch.fnmatch(filename, self._filename_pattern): return False if self.lineno is None: return True else: return (lineno == self.lineno) def _match_frame(self, filename, lineno): return self.__match_frame(filename, lineno) ^ (not self.inclusive) def _match_traceback(self, traceback): if self.all_frames: if any(self.__match_frame(filename, lineno) for filename, lineno in traceback): return self.inclusive else: return (not self.inclusive) else: filename, lineno = traceback[0] return self._match_frame(filename, lineno) class Snapshot: """ Snapshot of traces of memory blocks allocated by Python. """ def __init__(self, traces, traceback_limit): # traces is a tuple of trace tuples: see _Traces constructor for # the exact format self.traces = _Traces(traces) self.traceback_limit = traceback_limit def dump(self, filename): """ Write the snapshot into a file. """ with open(filename, "wb") as fp: pickle.dump(self, fp, pickle.HIGHEST_PROTOCOL) @staticmethod def load(filename): """ Load a snapshot from a file. """ with open(filename, "rb") as fp: return pickle.load(fp) def _filter_trace(self, include_filters, exclude_filters, trace): traceback = trace[1] if include_filters: if not any(trace_filter._match_traceback(traceback) for trace_filter in include_filters): return False if exclude_filters: if any(not trace_filter._match_traceback(traceback) for trace_filter in exclude_filters): return False return True def filter_traces(self, filters): """ Create a new Snapshot instance with a filtered traces sequence, filters is a list of Filter instances. If filters is an empty list, return a new Snapshot instance with a copy of the traces. """ if not isinstance(filters, Iterable): raise TypeError("filters must be a list of filters, not %s" % type(filters).__name__) if filters: include_filters = [] exclude_filters = [] for trace_filter in filters: if trace_filter.inclusive: include_filters.append(trace_filter) else: exclude_filters.append(trace_filter) new_traces = [trace for trace in self.traces._traces if self._filter_trace(include_filters, exclude_filters, trace)] else: new_traces = self.traces._traces.copy() return Snapshot(new_traces, self.traceback_limit) def _group_by(self, key_type, cumulative): if key_type not in ('traceback', 'filename', 'lineno'): raise ValueError("unknown key_type: %r" % (key_type,)) if cumulative and key_type not in ('lineno', 'filename'): raise ValueError("cumulative mode cannot by used " "with key type %r" % key_type) stats = {} tracebacks = {} if not cumulative: for trace in self.traces._traces: size, trace_traceback = trace try: traceback = tracebacks[trace_traceback] except KeyError: if key_type == 'traceback': frames = trace_traceback elif key_type == 'lineno': frames = trace_traceback[:1] else: # key_type == 'filename': frames = ((trace_traceback[0][0], 0),) traceback = Traceback(frames) tracebacks[trace_traceback] = traceback try: stat = stats[traceback] stat.size += size stat.count += 1 except KeyError: stats[traceback] = Statistic(traceback, size, 1) else: # cumulative statistics for trace in self.traces._traces: size, trace_traceback = trace for frame in trace_traceback: try: traceback = tracebacks[frame] except KeyError: if key_type == 'lineno': frames = (frame,) else: # key_type == 'filename': frames = ((frame[0], 0),) traceback = Traceback(frames) tracebacks[frame] = traceback try: stat = stats[traceback] stat.size += size stat.count += 1 except KeyError: stats[traceback] = Statistic(traceback, size, 1) return stats def statistics(self, key_type, cumulative=False): """ Group statistics by key_type. Return a sorted list of Statistic instances. """ grouped = self._group_by(key_type, cumulative) statistics = list(grouped.values()) statistics.sort(reverse=True, key=Statistic._sort_key) return statistics def compare_to(self, old_snapshot, key_type, cumulative=False): """ Compute the differences with an old snapshot old_snapshot. Get statistics as a sorted list of StatisticDiff instances, grouped by group_by. """ new_group = self._group_by(key_type, cumulative) old_group = old_snapshot._group_by(key_type, cumulative) statistics = _compare_grouped_stats(old_group, new_group) statistics.sort(reverse=True, key=StatisticDiff._sort_key) return statistics def take_snapshot(): """ Take a snapshot of traces of memory blocks allocated by Python. """ if not is_tracing(): raise RuntimeError("the tracemalloc module must be tracing memory " "allocations to take a snapshot") traces = _get_traces() traceback_limit = get_traceback_limit() return Snapshot(traces, traceback_limit)