ok

Mini Shell

Direktori : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/tracemalloc.cpython-36.opt-2.pyc

3


 \A�@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_tracescCszxtd
D]l}t|�dkr:|dkr:|r.d||fSd||fSt|�dksN|dkrj|r^d||fSd||fS|d
}qWdS)N�B�KiB�MiB�GiB�TiB�dz%+.1f %sz%.1f %s�
iz%+.0f %sz%.0f %s)rr	r
rri()�abs)�sizeZsignZunit�r�#/usr/lib64/python3.6/tracemalloc.py�_format_size
s
rc@s@eZdZdZdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�	Statistic�	tracebackr�countcCs||_||_||_dS)N)rrr)�selfrrrrrr�__init__%szStatistic.__init__cCst|j|j|jf�S)N)�hashrrr)rrrr�__hash__*szStatistic.__hash__cCs$|j|jko"|j|jko"|j|jkS)N)rrr)r�otherrrr�__eq__-szStatistic.__eq__cCsBd|jt|jd�|jf}|jr>|j|j}|dt|d�7}|S)Nz%s: size=%s, count=%iFz, average=%s)rrrr)r�text�averagerrr�__str__2s

zStatistic.__str__cCsd|j|j|jfS)Nz)<Statistic traceback=%r size=%i count=%i>)rrr)rrrr�__repr__<szStatistic.__repr__cCs|j|j|jfS)N)rrr)rrrr�	_sort_key@szStatistic._sort_keyN)rrr)
�__name__�
__module__�__qualname__�	__slots__rrrrr r!rrrrrs
rc@s@eZdZdZdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dS)�
StatisticDiffrr�	size_diffr�
count_diffcCs"||_||_||_||_||_dS)N)rrr'rr()rrrr'rr(rrrrKs
zStatisticDiff.__init__cCst|j|j|j|j|jf�S)N)rrrr'rr()rrrrrRszStatisticDiff.__hash__cCs<|j|jko:|j|jko:|j|jko:|j|jko:|j|jkS)N)rrr'rr()rrrrrrVs
zStatisticDiff.__eq__cCsPd|jt|jd�t|jd�|j|jf}|jrL|j|j}|dt|d�7}|S)Nz %s: size=%s (%s), count=%i (%+i)FTz, average=%s)rrrr'rr()rrrrrrr]s


zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>)rrr'rr()rrrrr iszStatisticDiff.__repr__cCs t|j�|jt|j�|j|jfS)N)rr'rr(rr)rrrrr!nszStatisticDiff._sort_keyN)rrr'rr()
r"r#r$r%rrrrr r!rrrrr&Dsr&cCs�g}xp|j�D]d\}}|j|d�}|dk	rPt||j|j|j|j|j|j�}nt||j|j|j|j�}|j|�qWx6|j�D]*\}}t|d|jd|j�}|j|�q�W|S)Nr)�items�popr&rr�append)�	old_group�	new_group�
statisticsr�statZpreviousrrr�_compare_grouped_statstsr0c@sXeZdZdZdd�Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Frame�_framecCs
||_dS)N)r2)r�framerrrr�szFrame.__init__cCs
|jdS)Nr)r2)rrrr�filename�szFrame.filenamecCs
|jdS)N�)r2)rrrr�lineno�szFrame.linenocCs|j|jkS)N)r2)rrrrrr�szFrame.__eq__cCs|j|jkS)N)r2)rrrrr�__lt__�szFrame.__lt__cCs
t|j�S)N)rr2)rrrrr�szFrame.__hash__cCsd|j|jfS)Nz%s:%s)r4r6)rrrrr�sz
Frame.__str__cCsd|j|jfS)Nz<Frame filename=%r lineno=%r>)r4r6)rrrrr �szFrame.__repr__N)r2)
r"r#r$r%r�propertyr4r6rr7rrr rrrrr1�sr1c@sbeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zddd�Z
dS)�	Traceback�_framescCstj|�||_dS)N)rrr:)r�framesrrrr�s
zTraceback.__init__cCs
t|j�S)N)�lenr:)rrrr�__len__�szTraceback.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdS)N)r1)�.0�tracerrr�	<genexpr>�sz(Traceback.__getitem__.<locals>.<genexpr>)�
isinstance�slice�tupler:r1)r�indexrrr�__getitem__�s
zTraceback.__getitem__cCs|j|jkS)N)r2r:)rr3rrr�__contains__�szTraceback.__contains__cCs
t|j�S)N)rr:)rrrrr�szTraceback.__hash__cCs|j|jkS)N)r:)rrrrrr�szTraceback.__eq__cCs|j|jkS)N)r:)rrrrrr7�szTraceback.__lt__cCst|d�S)Nr)�str)rrrrr�szTraceback.__str__cCsdt|�fS)Nz<Traceback %r>)rC)rrrrr �szTraceback.__repr__NcCsng}|dk	r|dkr|SxP|d|�D]@}|jd|j|jf�tj|j|j�j�}|r&|jd|�q&W|S)Nrz  File "%s", line %sz    %s)r+r4r6�	linecache�getline�strip)r�limit�linesr3�linerrr�format�szTraceback.format)r:)N)r"r#r$r%rr=rErFrrr7rr rNrrrrr9�sr9cCs t|�}|dk	rt|�SdSdS)N)rr9)�objr;rrr�get_object_traceback�srPc@s\eZdZdZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�Trace�_tracecCs
||_dS)N)rR)rr?rrrr�szTrace.__init__cCs
|jdS)Nr)rR)rrrr�domain�szTrace.domaincCs
|jdS)Nr5)rR)rrrrr�sz
Trace.sizecCst|jd�S)N�)r9rR)rrrrrszTrace.tracebackcCs|j|jkS)N)rR)rrrrrrszTrace.__eq__cCs
t|j�S)N)rrR)rrrrr
szTrace.__hash__cCsd|jt|jd�fS)Nz%s: %sF)rrr)rrrrr
sz
Trace.__str__cCsd|jt|jd�|jfS)Nz'<Trace domain=%s size=%s, traceback=%r>F)rSrrr)rrrrr szTrace.__repr__N)rR)
r"r#r$r%rr8rSrrrrrr rrrrrQ�srQc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCstj|�||_dS)N)rr�_traces)r�tracesrrrrs
z_Traces.__init__cCs
t|j�S)N)r<rV)rrrrr=sz_Traces.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdS)N)rQ)r>r?rrrr@ sz&_Traces.__getitem__.<locals>.<genexpr>)rArBrCrVrQ)rrDrrrrEs
z_Traces.__getitem__cCs|j|jkS)N)rRrV)rr?rrrrF$sz_Traces.__contains__cCs|j|jkS)N)rV)rrrrrr'sz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)r<)rrrrr *sz_Traces.__repr__N)	r"r#r$rr=rErFrr rrrrrUsrUcCs&tjj|�}|jd�r"|dd�}|S)Nz.pycr5���)�os�path�normcase�endswith)r4rrr�_normalize_filename.s
r]c@seZdZdd�Zdd�ZdS)�
BaseFiltercCs
||_dS)N)�	inclusive)rr_rrrr6szBaseFilter.__init__cCst�dS)N)�NotImplementedError)rr?rrr�_match9szBaseFilter._matchN)r"r#r$rrarrrrr^5sr^csJeZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t�j|�||_t|�|_||_||_||_dS)N)�superrr_r]�_filename_patternr6�
all_framesrS)rr_�filename_patternr6rerS)�	__class__rrr>s
zFilter.__init__cCs|jS)N)rd)rrrrrfGszFilter.filename_patterncCs6t|�}tj||j�sdS|jdkr(dS||jkSdS)NFT)r]�fnmatchrdr6)rr4r6rrr�_match_frame_implKs
zFilter._match_frame_implcCs|j||�|jAS)N)rir_)rr4r6rrr�_match_frameTszFilter._match_framecsH�jr,t�fdd�|D��r"�jS�jSn|d\}}�j||�SdS)Nc3s|]\}}�j||�VqdS)N)ri)r>r4r6)rrrr@Ysz*Filter._match_traceback.<locals>.<genexpr>r)re�anyr_rj)rrr4r6r)rr�_match_tracebackWs

zFilter._match_tracebackcCsD|\}}}|j|�}|jdk	r@|jr2|o0||jkS|p>||jkS|S)N)rlrSr_)rr?rSrr�resrrrrabs


z
Filter._match)NFN)r"r#r$rr8rfrirjrlra�
__classcell__rr)rgrrb=s	rbcs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst�j|�||_dS)N)rcr�_domain)rr_rS)rgrrrnszDomainFilter.__init__cCs|jS)N)rp)rrrrrSrszDomainFilter.domaincCs|\}}}||jk|jAS)N)rSr_)rr?rSrrrrrravs
zDomainFilter._match)r"r#r$rr8rSrarnrr)rgrromsroc@sTeZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	ddd�Z
ddd�ZdS)�SnapshotcCst|�|_||_dS)N)rUrW�traceback_limit)rrWrrrrrr�s
zSnapshot.__init__cCs*t|d��}tj||tj�WdQRXdS)N�wb)�open�pickle�dumpZHIGHEST_PROTOCOL)rr4�fprrrrv�sz
Snapshot.dumpc	Cs t|d��}tj|�SQRXdS)N�rb)rtru�load)r4rwrrrry�sz
Snapshot.loadcs@|rt�fdd�|D��sdS|r<t�fdd�|D��r<dSdS)Nc3s|]}|j��VqdS)N)ra)r>�trace_filter)r?rrr@�sz)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|j��VqdS)N)ra)r>rz)r?rrr@�sT)rk)r�include_filters�exclude_filtersr?r)r?r�
_filter_trace�s

zSnapshot._filter_tracecs�t|t�stdt|�j��|rng�g�x(|D] }|jrD�j|�q.�j|�q.W���fdd��jjD�}n�jjj	�}t
|�j�S)Nz)filters must be a list of filters, not %scsg|]}�j��|�r|�qSr)r})r>r?)r|r{rrr�
<listcomp>�sz*Snapshot.filter_traces.<locals>.<listcomp>)rAr�	TypeError�typer"r_r+rWrV�copyrqrr)r�filtersrzZ
new_tracesr)r|r{rr�
filter_traces�s

zSnapshot.filter_tracesc
Cs�|dkrtd|f��|r.|d	kr.td|��i}i}|�sx�|jjD]�}|\}}}y||}	WnZtk
r�|dkr~|}
n(|dkr�|dd�}
n|dddff}
t|
�}	|	||<YnXy(||	}|j|7_|jd7_WqFtk
�r
t|	|d�||	<YqFXqFWn�x�|jjD]�}|\}}}x�|D]�}y||}	WnFtk
�r�|dk�rd|f}
n|ddff}
t|
�}	|	||<YnXy(||	}|j|7_|jd7_Wn&tk
�r�t|	|d�||	<YnX�q0W�qW|S)
Nrr4r6zunknown key_type: %rz/cumulative mode cannot by used with key type %rr5r)rr4r6)r6r4)�
ValueErrorrWrV�KeyErrorr9rrr)
r�key_type�
cumulativeZstatsZ
tracebacksr?rSrZtrace_tracebackrr;r/r3rrr�	_group_by�sX



"zSnapshot._group_byFcCs,|j||�}t|j��}|jdtjd�|S)NT)�reverse�key)r��list�values�sortrr!)rr�r�Zgroupedr.rrrr.�szSnapshot.statisticscCs6|j||�}|j||�}t||�}|jdtjd�|S)NT)r�r�)r�r0r�r&r!)rZold_snapshotr�r�r-r,r.rrr�
compare_to�s

zSnapshot.compare_toN)F)F)r"r#r$rrv�staticmethodryr}r�r�r.r�rrrrrq{s3

rqcCs$t�std��t�}t�}t||�S)NzLthe tracemalloc module must be tracing memory allocations to take a snapshot)Z
is_tracing�RuntimeErrorrZget_traceback_limitrq)rWrrrrr�
take_snapshots
r�)�collectionsrr�	functoolsrrhrHZos.pathrYruZ_tracemallocrrrrr&r0r1r9rPrQrUr]r^rbrorqr�rrrr�<module>s0&0#5%0	

Zerion Mini Shell 1.0