ok

Mini Shell

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

a

���eF�@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@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�	StatisticzS
    Statistic difference on memory allocations between two Snapshot instance.
    ��	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__�__doc__�	__slots__rrrr"r#r$r
r
r
rrs
rc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�
StatisticDiffzd
    Statistic difference on memory allocations between an old and a new
    Snapshot instance.
    �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"��r7c@s\eZdZdZdZdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Framez
    Frame of a traceback.
    ��_framecCs
||_dSrr9�r�framer
r
rr�szFrame.__init__cCs
|jdSr/r9rr
r
r�filename�szFrame.filenamecCs
|jdS�N�r9rr
r
r�lineno�szFrame.linenocCst|t�stS|j|jkSr�rr8rr:rr
r
rr�s
zFrame.__eq__cCst|t�stS|j|jkSrrArr
r
r�__lt__�s
zFrame.__lt__cCs
t|j�Sr)rr:rr
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>rCrr
r
rr#�szFrame.__repr__N)r&r'r(r)r*r�propertyr=r@rrBrr"r#r
r
r
rr8�s

r8c@steZdZdZdZddd�Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zddd�ZdS)�	Tracebackz`
    Sequence of Frame instances sorted from the oldest frame
    to the most recent frame.
    )�_frames�
_total_nframeNcCs"t�|�tt|��|_||_dSr)rr�tuple�reversedrFrG)r�frames�total_nframer
r
rr�s
zTraceback.__init__cCs|jSr)rGrr
r
rrK�szTraceback.total_nframecCs
t|j�Sr)�lenrFrr
r
r�__len__�szTraceback.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)r8��.0�tracer
r
r�	<genexpr>��z(Traceback.__getitem__.<locals>.<genexpr>)r�slicerHrFr8�r�indexr
r
r�__getitem__�s
zTraceback.__getitem__cCs|j|jvSr)r:rFr;r
r
r�__contains__�szTraceback.__contains__cCs
t|j�Sr)rrFrr
r
rr�szTraceback.__hash__cCst|t�stS|j|jkSr�rrErrFrr
r
rr�s
zTraceback.__eq__cCst|t�stS|j|jkSrrXrr
r
rrB�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=)rHrGrK)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)rIr2r=r@�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer<�liner
r
r�format�s 
�zTraceback.format)N)NF)r&r'r(r)r*rrDrKrMrVrWrrrBr"r#rbr
r
r
rrE�s
	
rEcCs t|�}|durt|�SdSdS)z�
    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.
    N)rrE)�objrJr
r
r�get_object_tracebacksrdc@s`eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Tracez"
    Trace of a memory block.
    ��_tracecCs
||_dSrrf�rrPr
r
rrszTrace.__init__cCs
|jdSr/rfrr
r
r�domainszTrace.domaincCs
|jdSr>rfrr
r
rrsz
Trace.sizecCst|jdd��S)N�)rErgrr
r
rr#szTrace.tracebackcCst|t�stS|j|jkSr)rrerrgrr
r
rr's
zTrace.__eq__cCs
t|j�Sr)rrgrr
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)rirrrrr
r
rr#2s�zTrace.__repr__N)r&r'r(r)r*rrDrirrrrr"r#r
r
r
rres


rec@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)rLrlrr
r
rrM=sz_Traces.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)rerNr
r
rrQBrRz&_Traces.__getitem__.<locals>.<genexpr>)rrSrHrlrerTr
r
rrV@s
z_Traces.__getitem__cCs|j|jvSr)rgrlrhr
r
rrWFsz_Traces.__contains__cCst|t�stS|j|jkSr)rrkrrlrr
r
rrIs
z_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rLrr
r
rr#Nsz_Traces.__repr__N)	r&r'r(rrMrVrWrr#r
r
r
rrk7srkcCs&tj�|�}|�d�r"|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)r=r
r
r�_normalize_filenameRs
rsc@seZdZdd�Zdd�ZdS)�
BaseFiltercCs
||_dSr)�	inclusive)rrur
r
rrZszBaseFilter.__init__cCst�dSr)�NotImplementedErrorrhr
r
r�_match]szBaseFilter._matchN)r&r'r(rrwr
r
r
rrtYsrtcsJeZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dSr)�superrrurs�_filename_patternr@�
all_framesri)rru�filename_patternr@r{ri��	__class__r
rrbs
zFilter.__init__cCs|jSr)rzrr
r
rr|kszFilter.filename_patterncCs6t|�}t�||j�sdS|jdur(dS||jkSdS)NFT)rs�fnmatchrzr@�rr=r@r
r
r�_match_frame_implos
zFilter._match_frame_implcCs|�||�|jASr)r�rur�r
r
r�_match_framexszFilter._match_framecsH�jr,t�fdd�|D��r"�jS�jSn|d\}}��||�SdS)Nc3s|]\}}��||�VqdSr)r�)rOr=r@rr
rrQ}s�z*Filter._match_traceback.<locals>.<genexpr>r)r{�anyrur�)rrr=r@r
rr�_match_traceback{s�
zFilter._match_tracebackcCsF|\}}}}|�|�}|jdurB|jr4|o2||jkS|p@||jkS|Sr)r�riru)rrPrirrrK�resr
r
rrw�s

z
Filter._match)NFN)r&r'r(rrDr|r�r�r�rw�
__classcell__r
r
r}rrxas�	
	rxcs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dSr)ryr�_domain)rrurir}r
rr�szDomainFilter.__init__cCs|jSr)r�rr
r
rri�szDomainFilter.domaincCs|\}}}}||jk|jASr)riru)rrPrirrrKr
r
rrw�szDomainFilter._match)r&r'r(rrDrirwr�r
r
r}rr��s
r�c@sXeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
ddd�Zddd�ZdS)�SnapshotzB
    Snapshot of traces of memory blocks allocated by Python.
    cCst|�|_||_dSr)rkrm�traceback_limit)rrmr�r
r
rr�s
zSnapshot.__init__cCs>t|d�� }t�||tj�Wd�n1s00YdS)z1
        Write the snapshot into a file.
        �wbN)�open�pickle�dumpZHIGHEST_PROTOCOL)rr=�fpr
r
rr��sz
Snapshot.dumpcCs8t|d��}t�|�Wd�S1s*0YdS)z.
        Load a snapshot from a file.
        �rbN)r�r��load)r=r�r
r
rr��sz
Snapshot.loadcs@|rt�fdd�|D��sdS|r<t�fdd�|D��r<dSdS)Nc3s|]}|���VqdSr�rw�rO�trace_filter�rPr
rrQ�s�z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|���VqdSrr�r�r�r
rrQ�s�T)r�)r�include_filters�exclude_filtersrPr
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)z�
        Create a new Snapshot instance with a filtered traces sequence, filters
        is a list of Filter or DomainFilter instances.  If filters is an empty
        list, return a new Snapshot instance with a copy of the traces.
        z)filters must be a list of filters, not %scsg|]}����|�r|�qSr
)r�rN�r�r�rr
r�
<listcomp>�s
��z*Snapshot.filter_traces.<locals>.<listcomp>)rr�	TypeError�typer&rur2rmrl�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)�
ValueErrorrmrl�KeyErrorrErrr)r�key_type�
cumulativeZstatsZ
tracebacksrPrirZtrace_tracebackrKrrJr6r<r
r
r�	_group_by�sZ�
zSnapshot._group_byFcCs,|�||�}t|���}|jdtjd�|S)zd
        Group statistics by key_type. Return a sorted list of Statistic
        instances.
        T��reverse�key)r��list�values�sortrr$)rr�r�Zgroupedr5r
r
rr5szSnapshot.statisticscCs6|�||�}|�||�}t||�}|jdtjd�|S)z�
        Compute the differences with an old snapshot old_snapshot. Get
        statistics as a sorted list of StatisticDiff instances, grouped by
        group_by.
        Tr�)r�r7r�r+r$)rZold_snapshotr�r�r4r3r5r
r
r�
compare_tos

zSnapshot.compare_toN)F)F)
r&r'r(r)rr��staticmethodr�r�r�r�r5r�r
r
r
rr��s
3

r�cCs$t�std��t�}t�}t||�S)zI
    Take a snapshot of traces of memory blocks allocated by Python.
    zLthe tracemalloc module must be tracing memory allocations to take a snapshot)�
is_tracing�RuntimeErrorrZget_traceback_limitr�)rmr�r
r
r�
take_snapshot's
r�)�collections.abcrr�	functoolsrrr\Zos.pathror�Z_tracemallocrrrrr+r7r8rErdrerkrsrtrxr�r�r�r
r
r
r�<module>s2(2&M'0	

Zerion Mini Shell 1.0