AlkantarClanX12

Your IP : 13.59.95.170


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/__pycache__/tracemalloc.cpython-39.opt-2.pyc

a

R�fF�@sddlmZmZddlmZddlZddlZddlZddl	Z	ddl
Tddl
mZmZdd�Z
Gdd	�d	�ZGd
d�d�Zdd
�ZeGdd�d��ZeGdd�de��Zdd�ZGdd�d�ZGdd�de�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZGd d!�d!�Zd"d#�ZdS)$�)�Sequence�Iterable)�total_orderingN)�*)�_get_object_traceback�_get_tracescCs�dD]|}t|�dkr@|dkr@|r0d||fSd||fSt|�dksT|dkrx|rhd||fSd	||fS|d
}qdS)N)�BZKiBZMiBZGiB�TiB�drz%+.1f %sz%.1f %si(r	z%+.0f %sz%.0f %si)�abs)�sizeZsignZunit�r
�0/opt/alt/python39/lib64/python3.9/tracemalloc.py�_format_size
src@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�	Statistic��	tracebackr�countcCs||_||_||_dS�Nr)�selfrrrr
r
r�__init__%szStatistic.__init__cCst|j|j|jf�Sr)�hashrrr�rr
r
r�__hash__*szStatistic.__hash__cCs2t|t�stS|j|jko0|j|jko0|j|jkSr)�
isinstancer�NotImplementedrrr�r�otherr
r
r�__eq__-s

�
�zStatistic.__eq__cCsBd|jt|jd�|jf}|jr>|j|j}|dt|d�7}|S)Nz%s: size=%s, count=%iF�, average=%s)rrrr�r�textZaverager
r
r�__str__4s
��zStatistic.__str__cCsd|j|j|jfS)Nz)<Statistic traceback=%r size=%i count=%i>rrr
r
r�__repr__>s�zStatistic.__repr__cCs|j|j|jfSr)rrrrr
r
r�	_sort_keyBszStatistic._sort_keyN�
�__name__�
__module__�__qualname__�	__slots__rrrr"r#r$r
r
r
rrs
rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
StatisticDiff�rr�	size_diffr�
count_diffcCs"||_||_||_||_||_dSrr+)rrrr,rr-r
r
rrMs
zStatisticDiff.__init__cCst|j|j|j|j|jf�Sr)rrrr,rr-rr
r
rrTs�zStatisticDiff.__hash__cCsJt|t�stS|j|jkoH|j|jkoH|j|jkoH|j|jkoH|j|jkSr)rr*rrrr,rr-rr
r
rrXs

�
�
�
�zStatisticDiff.__eq__cCsPd|jt|jd�t|jd�|j|jf}|jrL|j|j}|dt|d�7}|S)Nz %s: size=%s (%s), count=%i (%+i)FTr)rrrr,rr-r r
r
rr"as

��zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>r+rr
r
rr#ms
��zStatisticDiff.__repr__cCs t|j�|jt|j�|j|jfSr)rr,rr-rrrr
r
rr$rs�zStatisticDiff._sort_keyNr%r
r
r
rr*Fs	r*cCs�g}|��D]d\}}|�|d�}|durNt||j|j|j|j|j|j�}nt||j|j|j|j�}|�|�q|��D]*\}}t|d|jd|j�}|�|�qz|S�Nr)�items�popr*rr�append)�	old_group�	new_group�
statisticsr�statZpreviousr
r
r�_compare_grouped_statsxs"��r6c@sXeZdZdZdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Frame��_framecCs
||_dSrr8�r�framer
r
rr�szFrame.__init__cCs
|jdSr.r8rr
r
r�filename�szFrame.filenamecCs
|jdS�N�r8rr
r
r�lineno�szFrame.linenocCst|t�stS|j|jkSr�rr7rr9rr
r
rr�s
zFrame.__eq__cCst|t�stS|j|jkSrr@rr
r
r�__lt__�s
zFrame.__lt__cCs
t|j�Sr)rr9rr
r
rr�szFrame.__hash__cCsd|j|jfS)Nz%s:%s�r<r?rr
r
rr"�sz
Frame.__str__cCsd|j|jfS)Nz<Frame filename=%r lineno=%r>rBrr
r
rr#�szFrame.__repr__N)
r&r'r(r)r�propertyr<r?rrArr"r#r
r
r
rr7�s

r7c@speZdZdZddd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zddd�ZdS)�	Traceback)�_frames�
_total_nframeNcCs"t�|�tt|��|_||_dSr)rr�tuple�reversedrErF)r�frames�total_nframer
r
rr�s
zTraceback.__init__cCs|jSr)rFrr
r
rrJ�szTraceback.total_nframecCs
t|j�Sr)�lenrErr
r
r�__len__�szTraceback.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)r7��.0�tracer
r
r�	<genexpr>��z(Traceback.__getitem__.<locals>.<genexpr>)r�slicerGrEr7�r�indexr
r
r�__getitem__�s
zTraceback.__getitem__cCs|j|jvSr)r9rEr:r
r
r�__contains__�szTraceback.__contains__cCs
t|j�Sr)rrErr
r
rr�szTraceback.__hash__cCst|t�stS|j|jkSr�rrDrrErr
r
rr�s
zTraceback.__eq__cCst|t�stS|j|jkSrrWrr
r
rrA�s
zTraceback.__lt__cCst|d�Sr.)�strrr
r
rr"�szTraceback.__str__cCs8dt|���}|jdur"|d7}n|d|j�d�7}|S)Nz<Traceback �>z total_nframe=)rGrFrJ)r�sr
r
rr#�s


zTraceback.__repr__FcCs�g}|dur2|dkr$||d�}q6|d|�}n|}|rBt|�}|D]@}|�d|j|jf�t�|j|j���}|rF|�d|�qF|S)Nrz  File "%s", line %sz    %s)rHr1r<r?�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer;�liner
r
r�format�s 
�zTraceback.format)N)NF)r&r'r(r)rrCrJrLrUrVrrrAr"r#rar
r
r
rrD�s
	
rDcCs t|�}|durt|�SdSdSr)rrD)�objrIr
r
r�get_object_tracebacksrcc@s\eZdZdZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Trace��_tracecCs
||_dSrre�rrOr
r
rrszTrace.__init__cCs
|jdSr.rerr
r
r�domainszTrace.domaincCs
|jdSr=rerr
r
rrsz
Trace.sizecCst|jdd��S)N�)rDrfrr
r
rr#szTrace.tracebackcCst|t�stS|j|jkSr)rrdrrfrr
r
rr's
zTrace.__eq__cCs
t|j�Sr)rrfrr
r
rr,szTrace.__hash__cCsd|jt|jd�fS)Nz%s: %sF)rrrrr
r
rr"/sz
Trace.__str__cCsd|jt|jd�|jfS)Nz'<Trace domain=%s size=%s, traceback=%r>F)rhrrrrr
r
rr#2s�zTrace.__repr__N)
r&r'r(r)rrCrhrrrrr"r#r
r
r
rrds


rdc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCst�|�||_dSr)rr�_traces)r�tracesr
r
rr8s
z_Traces.__init__cCs
t|j�Sr)rKrkrr
r
rrL=sz_Traces.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)rdrMr
r
rrPBrQz&_Traces.__getitem__.<locals>.<genexpr>)rrRrGrkrdrSr
r
rrU@s
z_Traces.__getitem__cCs|j|jvSr)rfrkrgr
r
rrVFsz_Traces.__contains__cCst|t�stS|j|jkSr)rrjrrkrr
r
rrIs
z_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rKrr
r
rr#Nsz_Traces.__repr__N)	r&r'r(rrLrUrVrr#r
r
r
rrj7srjcCs&tj�|�}|�d�r"|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)r<r
r
r�_normalize_filenameRs
rrc@seZdZdd�Zdd�ZdS)�
BaseFiltercCs
||_dSr)�	inclusive)rrtr
r
rrZszBaseFilter.__init__cCst�dSr)�NotImplementedErrorrgr
r
r�_match]szBaseFilter._matchN)r&r'r(rrvr
r
r
rrsYsrscsJeZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dSr)�superrrtrr�_filename_patternr?�
all_framesrh)rrt�filename_patternr?rzrh��	__class__r
rrbs
zFilter.__init__cCs|jSr)ryrr
r
rr{kszFilter.filename_patterncCs6t|�}t�||j�sdS|jdur(dS||jkSdS)NFT)rr�fnmatchryr?�rr<r?r
r
r�_match_frame_implos
zFilter._match_frame_implcCs|�||�|jASr)r�rtrr
r
r�_match_framexszFilter._match_framecsH�jr,t�fdd�|D��r"�jS�jSn|d\}}��||�SdS)Nc3s|]\}}��||�VqdSr)r�)rNr<r?rr
rrP}s�z*Filter._match_traceback.<locals>.<genexpr>r)rz�anyrtr�)rrr<r?r
rr�_match_traceback{s�
zFilter._match_tracebackcCsF|\}}}}|�|�}|jdurB|jr4|o2||jkS|p@||jkS|Sr)r�rhrt)rrOrhrrrJ�resr
r
rrv�s

z
Filter._match)NFN)r&r'r(rrCr{r�r�r�rv�
__classcell__r
r
r|rrwas�	
	rwcs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dSr)rxr�_domain)rrtrhr|r
rr�szDomainFilter.__init__cCs|jSr)r�rr
r
rrh�szDomainFilter.domaincCs|\}}}}||jk|jASr)rhrt)rrOrhrrrJr
r
rrv�szDomainFilter._match)r&r'r(rrCrhrvr�r
r
r|rr��s
r�c@sTeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	ddd�Z
ddd�ZdS)�SnapshotcCst|�|_||_dSr)rjrl�traceback_limit)rrlr�r
r
rr�s
zSnapshot.__init__cCs>t|d�� }t�||tj�Wd�n1s00YdS)N�wb)�open�pickle�dumpZHIGHEST_PROTOCOL)rr<�fpr
r
rr��sz
Snapshot.dumpcCs8t|d��}t�|�Wd�S1s*0YdS)N�rb)r�r��load)r<r�r
r
rr��sz
Snapshot.loadcs@|rt�fdd�|D��sdS|r<t�fdd�|D��r<dSdS)Nc3s|]}|���VqdSr�rv�rN�trace_filter�rOr
rrP�s�z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|���VqdSrr�r�r�r
rrP�s�T)r�)r�include_filters�exclude_filtersrOr
r�r�
_filter_trace�s��zSnapshot._filter_tracecs�t|t�stdt|�j��|rjg�g�|D] }|jrB��|�q,��|�q,���fdd��jjD�}n�jj�	�}t
|�j�S)Nz)filters must be a list of filters, not %scsg|]}����|�r|�qSr
)r�rM�r�r�rr
r�
<listcomp>�s
��z*Snapshot.filter_traces.<locals>.<listcomp>)rr�	TypeError�typer&rtr1rlrk�copyr�r�)r�filtersr�Z
new_tracesr
r�r�
filter_traces�s
�zSnapshot.filter_tracesc
Cs�|dvrtd|f��|r.|dvr.td|��i}i}|�s|jjD]�}|\}}}}	z||}
WnXty�|dkr||}n(|dkr�|dd�}n|dddff}t|�}
|
||<Yn0z(||
}|j|7_|jd7_WqDt�yt|
|d�||
<YqD0qDn�|jjD]�}|\}}}}	|D]�}
z||
}
WnDt�y||dk�rZ|
f}n|
ddff}t|�}
|
||
<Yn0z(||
}|j|7_|jd7_Wn$t�y�t|
|d�||
<Yn0�q(�q|S)	N)rr<r?zunknown key_type: %r)r?r<z/cumulative mode cannot by used with key type %rrr?r>r)�
ValueErrorrlrk�KeyErrorrDrrr)r�key_type�
cumulativeZstatsZ
tracebacksrOrhrZtrace_tracebackrJrrIr5r;r
r
r�	_group_by�sZ�
zSnapshot._group_byFcCs,|�||�}t|���}|jdtjd�|S�NT)�reverse�key)r��list�values�sortrr$)rr�r�Zgroupedr4r
r
rr4szSnapshot.statisticscCs6|�||�}|�||�}t||�}|jdtjd�|Sr�)r�r6r�r*r$)rZold_snapshotr�r�r3r2r4r
r
r�
compare_tos

zSnapshot.compare_toN)F)F)r&r'r(rr��staticmethodr�r�r�r�r4r�r
r
r
rr��s
3

r�cCs$t�std��t�}t�}t||�S)NzLthe tracemalloc module must be tracing memory allocations to take a snapshot)�
is_tracing�RuntimeErrorrZget_traceback_limitr�)rlr�r
r
r�
take_snapshot's
r�)�collections.abcrr�	functoolsrr~r[Zos.pathrnr�Z_tracemallocrrrrr*r6r7rDrcrdrjrrrsrwr�r�r�r
r
r
r�<module>s2(2&M'0