Your IP : 3.144.104.175


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/tracemalloc.cpython-310.opt-2.pyc

o

6��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 |rd||fSd||fSt|�dks*|dkr<|r4d||fSd	||fS|d
}qdS)N)�BZKiBZMiBZGiB�TiB�drz%+.1f %sz%.1f %si(r	z%+.0f %sz%.0f %si)�abs)�sizeZsignZunit�r
�2/opt/alt/python310/lib64/python3.10/tracemalloc.py�_format_size
s
�rc@�BeZdZ	dZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�	Statistic��	tracebackr�countcCs||_||_||_dS�Nr)�selfrrrr
r
r�__init__%s
zStatistic.__init__cCst|j|j|jf�Sr)�hashrrr�rr
r
r�__hash__*�zStatistic.__hash__cCs2t|t�stS|j|jko|j|jko|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_keyB�zStatistic._sort_keyN�
�__name__�
__module__�__qualname__�	__slots__rrr r$r%r&r
r
r
rrs
rc@r)�
StatisticDiff�rr�	size_diffr�
count_diffcCs"||_||_||_||_||_dSrr.)rrrr/rr0r
r
rrMs

zStatisticDiff.__init__cCst|j|j|j|j|jf�Sr)rrrr/rr0rr
r
rrTs�zStatisticDiff.__hash__cCsJt|t�stS|j|jko$|j|jko$|j|jko$|j|jko$|j|jkSr)rr-rrrr/rr0rr
r
rr Xs

�
�
�
�zStatisticDiff.__eq__cCsPd|jt|jd�t|jd�|j|jf}|jr&|j|j}|dt|d�7}|S)Nz %s: size=%s (%s), count=%i (%+i)FTr!)rrrr/rr0r"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r0rrrr
r
rr&rs�zStatisticDiff._sort_keyNr(r
r
r
rr-Fs	r-cCs�g}|��D]2\}}|�|d�}|dur't||j|j|j|j|j|j�}nt||j|j|j|j�}|�|�q|��D]\}}t|d|jd|j�}|�|�q=|S�Nr)�items�popr-rr�append)�	old_group�	new_group�
statisticsr�statZpreviousr
r
r�_compare_grouped_statsxs"��r9c@sZeZdZ	dZdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Frame��_framecC�
||_dSrr;�r�framer
r
rr��
zFrame.__init__cC�
|jdSr1r;rr
r
r�filename�r@zFrame.filenamecCrA�N�r;rr
r
r�lineno�r@zFrame.linenocC�t|t�stS|j|jkSr�rr:rr<rr
r
rr ��
zFrame.__eq__cC�t|t�stS|j|jkSrrGrr
r
r�__lt__�rHzFrame.__lt__cC�
t|j�Sr)rr<rr
r
rr��
zFrame.__hash__cC�d|j|jfS)Nz%s:%s�rBrErr
r
rr$�r'z
Frame.__str__cCrM)Nz<Frame filename=%r lineno=%r>rNrr
r
rr%�r'zFrame.__repr__N)
r)r*r+r,r�propertyrBrEr rJrr$r%r
r
r
rr:�s

r:c@sreZdZ	dZddd�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�reversedrQrR)r�frames�total_nframer
r
rr�s

zTraceback.__init__cC�|jSr)rRrr
r
rrV��zTraceback.total_nframecCrKr)�lenrQrr
r
r�__len__�rLzTraceback.__len__cC�0t|t�rtdd�|j|D��St|j|�S)Ncs��|]}t|�VqdSr)r:��.0�tracer
r
r�	<genexpr>���z(Traceback.__getitem__.<locals>.<genexpr>)r�slicerSrQr:�r�indexr
r
r�__getitem__��
zTraceback.__getitem__cC�|j|jvSr)r<rQr>r
r
r�__contains__��zTraceback.__contains__cCrKr)rrQrr
r
rr�rLzTraceback.__hash__cCrFr�rrPrrQrr
r
rr �rHzTraceback.__eq__cCrIrrjrr
r
rrJ�rHzTraceback.__lt__cCst|d�Sr1)�strrr
r
rr$�rizTraceback.__str__cCs:dt|���}|jdur|d7}|S|d|j�d�7}|S)Nz<Traceback �>z total_nframe=)rSrRrV)r�sr
r
rr%�s
�zTraceback.__repr__FcCs�g}|dur|dkr||d�}n	|d|�}n|}|r!t|�}|D] }|�d|j|jf�t�|j|j���}|rC|�d|�q#|S)Nrz  File "%s", line %sz    %s)rTr4rBrE�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer?�liner
r
r�format�s"
��zTraceback.formatr)NF)r)r*r+r,rrOrVrZrerhrr rJr$r%rtr
r
r
rrP�s
	
rPcCs	t|�}|dur
t|�SdSr)rrP)�objrUr
r
r�get_object_tracebacks
rvc@s^eZdZ	dZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Trace��_tracecCr=rrx�rr_r
r
rrs
zTrace.__init__cCrAr1rxrr
r
r�domainr@zTrace.domaincCrArCrxrr
r
rrr@z
Trace.sizecCst|jdd��S)N�)rPryrr
r
rr#szTrace.tracebackcCrFr)rrwrryrr
r
rr 'rHzTrace.__eq__cCrKr)rryrr
r
rr,rLzTrace.__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)r{rrrrr
r
rr%2s�zTrace.__repr__N)
r)r*r+r,rrOr{rrr rr$r%r
r
r
rrws


rwc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCst�|�||_dSr)rr�_traces)r�tracesr
r
rr8s

z_Traces.__init__cCrKr)rYr~rr
r
rrZ=rLz_Traces.__len__cCr[)Ncsr\r)rwr]r
r
rr`Braz&_Traces.__getitem__.<locals>.<genexpr>)rrbrSr~rwrcr
r
rre@rfz_Traces.__getitem__cCrgr)ryr~rzr
r
rrhFriz_Traces.__contains__cCrFr)rr}rr~rr
r
rr IrHz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rYrr
r
rr%Nriz_Traces.__repr__N)	r)r*r+rrZrerhr r%r
r
r
rr}7sr}cCs&tj�|�}|�d�r|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)rBr
r
r�_normalize_filenameRs
r�c@seZdZdd�Zdd�ZdS)�
BaseFiltercCr=r)�	inclusive)rr�r
r
rrZrLzBaseFilter.__init__cCst�r)�NotImplementedErrorrzr
r
r�_match]szBaseFilter._matchN)r)r*r+rr�r
r
r
rr�Ysr�csLeZdZ	d�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dSr)�superrr�r��_filename_patternrE�
all_framesr{)rr��filename_patternrEr�r{��	__class__r
rrbs

zFilter.__init__cCrWr)r�rr
r
rr�krXzFilter.filename_patterncCs2t|�}t�||j�s
dS|jdurdS||jkS)NFT)r��fnmatchr�rE�rrBrEr
r
r�_match_frame_implos

zFilter._match_frame_implcCs|�||�|jASr)r�r�r�r
r
r�_match_framexrzFilter._match_framecsB�jrt�fdd�|D��r�jS�jS|d\}}��||�S)Nc3s �|]\}}��||�VqdSr)r�)r^rBrErr
rr`}s��z*Filter._match_traceback.<locals>.<genexpr>r)r��anyr�r�)rrrBrEr
rr�_match_traceback{s�zFilter._match_tracebackcCsF|\}}}}|�|�}|jdur!|jr|o||jkS|p ||jkS|Sr)r�r{r�)rr_r{rrrV�resr
r
rr��s

z
Filter._match)NFN)r)r*r+rrOr�r�r�r�r��
__classcell__r
r
r�rr�as�	
	r�cs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dSr)r�r�_domain)rr�r{r�r
rr�s
zDomainFilter.__init__cCrWr)r�rr
r
rr{�rXzDomainFilter.domaincCs|\}}}}||jk|jASr)r{r�)rr_r{rrrVr
r
rr��szDomainFilter._match)r)r*r+rrOr{r�r�r
r
r�rr��s

r�c@sVeZdZ	dd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	ddd�Z
ddd�ZdS)�SnapshotcCst|�|_||_dSr)r}r�traceback_limit)rrr�r
r
rr�s

zSnapshot.__init__cCsB	t|d��}t�||tj�Wd�dS1swYdS)N�wb)�open�pickle�dumpZHIGHEST_PROTOCOL)rrB�fpr
r
rr��s"�z
Snapshot.dumpcCs:	t|d��
}t�|�Wd�S1swYdS)N�rb)r�r��load)rBr�r
r
rr��s$�z
Snapshot.loadcs@|rt�fdd�|D��sdS|rt�fdd�|D��rdSdS)Nc3s�|]}|���VqdSr�r��r^�trace_filter�r_r
rr`�s��z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s�|]	}|���VqdSrr�r�r�r
rr`�s��T)r�)r�include_filters�exclude_filtersr_r
r�r�
_filter_trace�s��zSnapshot._filter_tracecs�	t|t�stdt|�j��|r6g�g�|D]}|jr"��|�q��|�q���fdd��jjD�}n�jj�	�}t
|�j�S)Nz)filters must be a list of filters, not %scsg|]}����|�r|�qSr
)r�r]�r�r�rr
r�
<listcomp>�s�
�z*Snapshot.filter_traces.<locals>.<listcomp>)rr�	TypeError�typer)r�r4rr~�copyr�r�)r�filtersr�Z
new_tracesr
r�r�
filter_traces�s
�zSnapshot.filter_tracesc
Cs�|dvrtd|f��|r|dvrtd|��i}i}|s�|jjD]`}|\}}}}	z||}
Wn,ty[|dkr=|}n|dkrH|dd�}n	|dddff}t|�}
|
||<Ynwz||
}|j|7_|jd7_Wq!ty�t|
|d�||
<Yq!w|S|jjD]Y}|\}}}}	|D]N}
z||
}
Wn ty�|dkr�|
f}n|
ddff}t|�}
|
||
<Ynwz||
}|j|7_|jd7_Wq�ty�t|
|d�||
<Yq�wq�|S)	N)rrBrEzunknown key_type: %r)rErBz/cumulative mode cannot by used with key type %rrrErDr)�
ValueErrorrr~�KeyErrorrPrrr)r�key_type�
cumulativeZstatsZ
tracebacksr_r{rZtrace_tracebackrVrrUr8r?r
r
r�	_group_by�sf��	�����zSnapshot._group_byFcCs.	|�||�}t|���}|jdtjd�|S�NT)�reverse�key)r��list�values�sortrr&)rr�r�Zgroupedr7r
r
rr7s
zSnapshot.statisticscCs8	|�||�}|�||�}t||�}|jdtjd�|Sr�)r�r9r�r-r&)rZold_snapshotr�r�r6r5r7r
r
r�
compare_tos
zSnapshot.compare_toN)F)r)r*r+rr��staticmethodr�r�r�r�r7r�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�)rr�r
r
r�
take_snapshot's
r�)Zcollections.abcrr�	functoolsrr�rnZos.pathr�r�Z_tracemallocrrrrr-r9r:rPrvrwr}r�r�r�r�r�r�r
r
r
r�<module>s4(2&M'0	

?>