AlkantarClanX12

Your IP : 3.138.122.90


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/tracemalloc.cpython-310.opt-1.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@�DeZdZdZdZdd�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__%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__�__doc__�	__slots__rrr r$r%r&r
r
r
rrs
rc@r)�
StatisticDiffzd
    Statistic difference on memory allocations between an old and a new
    Snapshot instance.
    �rr�	size_diffr�
count_diffcCs"||_||_||_||_||_dSrr/)rrrr0rr1r
r
rrMs

zStatisticDiff.__init__cCst|j|j|j|j|jf�Sr)rrrr0rr1rr
r
rrTs�zStatisticDiff.__hash__cCsJt|t�stS|j|jko$|j|jko$|j|jko$|j|jko$|j|jkSr)rr.rrrr0rr1rr
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r0rr1r"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)rr0rr1rrrr
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"��r:c@s\eZdZdZdZdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Framez
    Frame of a traceback.
    ��_framecC�
||_dSrr<�r�framer
r
rr��
zFrame.__init__cC�
|jdSr2r<rr
r
r�filename�rAzFrame.filenamecCrB�N�r<rr
r
r�lineno�rAzFrame.linenocC�t|t�stS|j|jkSr�rr;rr=rr
r
rr ��
zFrame.__eq__cC�t|t�stS|j|jkSrrHrr
r
r�__lt__�rIzFrame.__lt__cC�
t|j�Sr)rr=rr
r
rr��
zFrame.__hash__cC�d|j|jfS)Nz%s:%s�rCrFrr
r
rr$�r'z
Frame.__str__cCrN)Nz<Frame filename=%r lineno=%r>rOrr
r
rr%�r'zFrame.__repr__N)r)r*r+r,r-r�propertyrCrFr rKrr$r%r
r
r
rr;�s

r;c@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�reversedrRrS)r�frames�total_nframer
r
rr�s

zTraceback.__init__cC�|jSr)rSrr
r
rrW��zTraceback.total_nframecCrLr)�lenrRrr
r
r�__len__�rMzTraceback.__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�slicerTrRr;�r�indexr
r
r�__getitem__��
zTraceback.__getitem__cC�|j|jvSr)r=rRr?r
r
r�__contains__��zTraceback.__contains__cCrLr)rrRrr
r
rr�rMzTraceback.__hash__cCrGr�rrQrrRrr
r
rr �rIzTraceback.__eq__cCrJrrkrr
r
rrK�rIzTraceback.__lt__cCst|d�Sr2)�strrr
r
rr$�rjzTraceback.__str__cCs:dt|���}|jdur|d7}|S|d|j�d�7}|S)Nz<Traceback �>z total_nframe=)rTrSrW)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)rUr5rCrF�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer@�liner
r
r�format�s"
��zTraceback.formatr)NF)r)r*r+r,r-rrPrWr[rfrirr rKr$r%rur
r
r
rrQ�s
	
rQcCst|�}|durt|�SdS)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)rrQ)�objrVr
r
r�get_object_tracebacksrwc@s`eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Tracez"
    Trace of a memory block.
    ��_tracecCr>rry�rr`r
r
rrs
zTrace.__init__cCrBr2ryrr
r
r�domainrAzTrace.domaincCrBrDryrr
r
rrrAz
Trace.sizecCst|jdd��S)N�)rQrzrr
r
rr#szTrace.tracebackcCrGr)rrxrrzrr
r
rr 'rIzTrace.__eq__cCrLr)rrzrr
r
rr,rMzTrace.__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,r-rrPr|rrr rr$r%r
r
r
rrxs


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

z_Traces.__init__cCrLr)rZrrr
r
rr[=rMz_Traces.__len__cCr\)Ncsr]r)rxr^r
r
rraBrbz&_Traces.__getitem__.<locals>.<genexpr>)rrcrTrrxrdr
r
rrf@rgz_Traces.__getitem__cCrhr)rzrr{r
r
rriFrjz_Traces.__contains__cCrGr)rr~rrrr
r
rr IrIz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rZrr
r
rr%Nrjz_Traces.__repr__N)	r)r*r+rr[rfrir r%r
r
r
rr~7sr~cCs&tj�|�}|�d�r|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)rCr
r
r�_normalize_filenameRs
r�c@seZdZdd�Zdd�ZdS)�
BaseFiltercCr>r)�	inclusive)rr�r
r
rrZrMzBaseFilter.__init__cCst�r)�NotImplementedErrorr{r
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_patternrF�
all_framesr|)rr��filename_patternrFr�r|��	__class__r
rrbs

zFilter.__init__cCrXr)r�rr
r
rr�krYzFilter.filename_patterncCs2t|�}t�||j�s
dS|jdurdS||jkS)NFT)r��fnmatchr�rF�rrCrFr
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_rCrFrr
rra}s��z*Filter._match_traceback.<locals>.<genexpr>r)r��anyr�r�)rrrCrFr
rr�_match_traceback{s�zFilter._match_tracebackcCsF|\}}}}|�|�}|jdur!|jr|o||jkS|p ||jkS|Sr)r�r|r�)rr`r|rrrW�resr
r
rr��s

z
Filter._match)NFN)r)r*r+rrPr�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__cCrXr)r�rr
r
rr|�rYzDomainFilter.domaincCs|\}}}}||jk|jASr)r|r�)rr`r|rrrWr
r
rr��szDomainFilter._match)r)r*r+rrPr|r�r�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)r~r��traceback_limit)rr�r�r
r
rr�s

zSnapshot.__init__cCs@t|d��}t�||tj�Wd�dS1swYdS)z1
        Write the snapshot into a file.
        �wbN)�open�pickle�dumpZHIGHEST_PROTOCOL)rrC�fpr
r
rr��s"�z
Snapshot.dumpcCs8t|d��
}t�|�Wd�S1swYdS)z.
        Load a snapshot from a file.
        �rbN)r�r��load)rCr�r
r
rr��s$�z
Snapshot.loadcs@|rt�fdd�|D��sdS|rt�fdd�|D��rdSdS)Nc3s�|]}|���VqdSr�r��r_�trace_filter�r`r
rra�s��z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s�|]	}|���VqdSrr�r�r�r
rra�s��T)r�)r�include_filters�exclude_filtersr`r
r�r�
_filter_trace�s��zSnapshot._filter_tracecs�t|t�stdt|�j��|r5g�g�|D]}|jr!��|�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�r^�r�r�rr
r�
<listcomp>�s�
�z*Snapshot.filter_traces.<locals>.<listcomp>)rr�	TypeError�typer)r�r5r�r�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)rrCrFzunknown key_type: %r)rFrCz/cumulative mode cannot by used with key type %rrrFrEr)�
ValueErrorr�r�KeyErrorrQrrr)r�key_type�
cumulativeZstatsZ
tracebacksr`r|rZtrace_tracebackrWrrVr9r@r
r
r�	_group_by�sf��	�����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�Zgroupedr8r
r
rr8s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�r:r�r.r&)rZold_snapshotr�r�r7r6r8r
r
r�
compare_tos

zSnapshot.compare_toN)F)
r)r*r+r,rr��staticmethodr�r�r�r�r8r�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�)r�r�r
r
r�
take_snapshot's

r�)Zcollections.abcrr�	functoolsrr�roZos.pathr�r�Z_tracemallocrrrrr.r:r;rQrwrxr~r�r�r�r�r�r�r
r
r
r�<module>s4(2&M'0