Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /opt/alt/python38/lib64/python3.8/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python38/lib64/python3.8/__pycache__/tracemalloc.cpython-38.opt-1.pyc
U

��,a�B�@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/python38/lib64/python3.8/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__cCs$|j|jko"|j|jko"|j|jkSrr�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__2s
��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_key@szStatistic._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
rrKs
zStatisticDiff.__init__cCst|j|j|j|j|jf�Sr)rrrr+rr,rr
r
rrRs�zStatisticDiff.__hash__cCs<|j|jko:|j|jko:|j|jko:|j|jko:|j|jkSrr*rr
r
rrVs
�
�
�
�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,rr
r
rr ]s

��zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>r*rr
r
rr!is��zStatisticDiff.__repr__cCs t|j�|jt|j�|j|jfSr)rr+rr,rrrr
r
rr"ns
�zStatisticDiff._sort_keyNr#r
r
r
rr)Dsr)cCs�g}|��D]d\}}|�|d�}|dk	rNt||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_statsts*

��r5c@s\eZdZdZdZdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Framez
    Frame of a traceback.
    ��_framecCs
||_dSrr7�r�framer
r
rr�szFrame.__init__cCs
|jdSr-r7rr
r
r�filename�szFrame.filenamecCs
|jdS�N�r7rr
r
r�lineno�szFrame.linenocCs|j|jkSrr7rr
r
rr�szFrame.__eq__cCs|j|jkSrr7rr
r
r�__lt__�szFrame.__lt__cCs
t|j�Sr)rr8rr
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>r@rr
r
rr!�szFrame.__repr__N)r$r%r&r'r(r�propertyr;r>rr?rr r!r
r
r
rr6�s

r6c@sfeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddd�ZdS)�	Tracebackz`
    Sequence of Frame instances sorted from the oldest frame
    to the most recent frame.
    ��_framescCst�|�tt|��|_dSr)rr�tuple�reversedrD)r�framesr
r
rr�s
zTraceback.__init__cCs
t|j�Sr)�lenrDrr
r
r�__len__�szTraceback.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)r6��.0�tracer
r
r�	<genexpr>�sz(Traceback.__getitem__.<locals>.<genexpr>)�
isinstance�slicerErDr6�r�indexr
r
r�__getitem__�s
zTraceback.__getitem__cCs|j|jkSr)r8rDr9r
r
r�__contains__�szTraceback.__contains__cCs
t|j�Sr)rrDrr
r
rr�szTraceback.__hash__cCs|j|jkSrrCrr
r
rr�szTraceback.__eq__cCs|j|jkSrrCrr
r
rr?�szTraceback.__lt__cCst|d�Sr-)�strrr
r
rr �szTraceback.__str__cCsdt|�fS)Nz<Traceback %r>)rErr
r
rr!�szTraceback.__repr__NFcCs�g}|dk	r2|dkr$||d�}q6|d|�}n|}|rBt|�}|D]@}|�d|j|jf�t�|j|j���}|rF|�d|�qF|S)Nrz  File "%s", line %sz    %s)rFr0r;r>�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer:�liner
r
r�format�s 
�zTraceback.format)NF)r$r%r&r'r(rrIrRrSrrr?r r!r[r
r
r
rrB�srBcCs t|�}|dk	rt|�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)rrB)�objrGr
r
r�get_object_traceback�sr]c@s`eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Tracez"
    Trace of a memory block.
    ��_tracecCs
||_dSrr_�rrLr
r
rrszTrace.__init__cCs
|jdSr-r_rr
r
r�domainszTrace.domaincCs
|jdSr<r_rr
r
rr	sz
Trace.sizecCst|jd�S)N�)rBr`rr
r
rr
szTrace.tracebackcCs|j|jkSrr_rr
r
rrszTrace.__eq__cCs
t|j�Sr)rr`rr
r
rrszTrace.__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)rbrrrrr
r
rr!s�zTrace.__repr__N)r$r%r&r'r(rrArbrrrrr r!r
r
r
rr^�s


r^c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCst�|�||_dSr)rr�_traces)r�tracesr
r
rr s
z_Traces.__init__cCs
t|j�Sr)rHrerr
r
rrI%sz_Traces.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdSr)r^rJr
r
rrM*sz&_Traces.__getitem__.<locals>.<genexpr>)rNrOrErer^rPr
r
rrR(s
z_Traces.__getitem__cCs|j|jkSr)r`rerar
r
rrS.sz_Traces.__contains__cCs|j|jkSr)rerr
r
rr1sz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rHrr
r
rr!4sz_Traces.__repr__N)	r$r%r&rrIrRrSrr!r
r
r
rrdsrdcCs&tj�|�}|�d�r"|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)r;r
r
r�_normalize_filename8s
rlc@seZdZdd�Zdd�ZdS)�
BaseFiltercCs
||_dSr)�	inclusive)rrnr
r
rr@szBaseFilter.__init__cCst�dSr)�NotImplementedErrorrar
r
r�_matchCszBaseFilter._matchN)r$r%r&rrpr
r
r
rrm?srmcsJeZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dSr)�superrrnrl�_filename_patternr>�
all_framesrb)rrn�filename_patternr>rtrb��	__class__r
rrHs
zFilter.__init__cCs|jSr)rsrr
r
rruQszFilter.filename_patterncCs6t|�}t�||j�sdS|jdkr(dS||jkSdS)NFT)rl�fnmatchrsr>�rr;r>r
r
r�_match_frame_implUs
zFilter._match_frame_implcCs|�||�|jASr)rzrnryr
r
r�_match_frame^szFilter._match_framecsH�jr,t�fdd�|D��r"�jS�jSn|d\}}��||�SdS)Nc3s|]\}}��||�VqdSr)rz)rKr;r>rr
rrMcs�z*Filter._match_traceback.<locals>.<genexpr>r)rt�anyrnr{)rrr;r>r
rr�_match_tracebackas�
zFilter._match_tracebackcCsD|\}}}|�|�}|jdk	r@|jr2|o0||jkS|p>||jkS|Sr)r}rbrn)rrLrbrr�resr
r
rrpls


z
Filter._match)NFN)r$r%r&rrArurzr{r}rp�
__classcell__r
r
rvrrqGs�	
	rqcs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dSr)rrr�_domain)rrnrbrvr
rrxszDomainFilter.__init__cCs|jSr)r�rr
r
rrb|szDomainFilter.domaincCs|\}}}||jk|jASr)rbrn)rrLrbrrr
r
rrp�s
zDomainFilter._match)r$r%r&rrArbrprr
r
rvrr�ws
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)rdrf�traceback_limit)rrfr�r
r
rr�s
zSnapshot.__init__c	Cs*t|d��}t�||tj�W5QRXdS)z1
        Write the snapshot into a file.
        �wbN)�open�pickle�dumpZHIGHEST_PROTOCOL)rr;�fpr
r
rr��sz
Snapshot.dumpc
Cs,t|d��}t�|�W5QR�SQRXdS)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�rp�rK�trace_filter�rLr
rrM�s�z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|���VqdSrr�r�r�r
rrM�s�T)r|)r�include_filters�exclude_filtersrLr
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�rJ�r�r�rr
r�
<listcomp>�s��z*Snapshot.filter_traces.<locals>.<listcomp>)rNr�	TypeError�typer$rnr0rfre�copyr�r�)r�filtersr�Z
new_tracesr
r�r�
filter_traces�s
�zSnapshot.filter_tracesc

Cs�|dkrtd|f��|r.|dkr.td|��i}i}|�s|jjD]�}|\}}}z||}	WnZtk
r�|dkr||}
n(|dkr�|dd�}
n|dddff}
t|
�}	|	||<YnXz(||	}|j|7_|jd7_WqDtk
�rt|	|d�||	<YqDXqDn�|jjD]�}|\}}}|D]�}z||}	WnFtk
�r~|dk�r\|f}
n|ddff}
t|
�}	|	||<YnXz(||	}|j|7_|jd7_Wn&tk
�r�t|	|d�||	<YnX�q(�q|S)	N)rr;r>zunknown key_type: %r)r>r;z/cumulative mode cannot by used with key type %rrr>r=r)�
ValueErrorrfre�KeyErrorrBrrr)
r�key_type�
cumulativeZstatsZ
tracebacksrLrbrZtrace_tracebackrrGr4r: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�Zgroupedr3r
r
rr3�s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�r5r�r)r")rZold_snapshotr�r�r2r1r3r
r
r�
compare_tos

zSnapshot.compare_toN)F)F)
r$r%r&r'rr��staticmethodr�r�r�r�r3r�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�)rfr�r
r
r�
take_snapshot
s
r�)Zcollections.abcrr�	functoolsrrxrUZos.pathrhr�Z_tracemallocrrrrr)r5r6rBr]r^rdrlrmrqr�r�r�r
r
r
r�<module>s2&0"?%0	

ZeroDay Forums Mini