HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/__pycache__/tracemalloc.cpython-37.pyc
B

��g�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_tracescCszxtdD]l}t|�dkr:|dkr:|r.d||fSd||fSt|�dksN|dkrj|r^d||fSd	||fS|d
}qWdS)N)�BZKiBZMiBZGiB�TiB�drz%+.1f %sz%.1f %si(r	z%+.0f %sz%.0f %si)�abs)�size�signZunit�r�'/usr/local/lib/python3.7/tracemalloc.py�_format_size
s
rc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�	StatisticzS
    Statistic difference on memory allocations between two Snapshot instance.
    )�	tracebackr�countcCs||_||_||_dS)N)rrr)�selfrrrrrr�__init__%szStatistic.__init__cCst|j|j|jf�S)N)�hashrrr)rrrr�__hash__*szStatistic.__hash__cCs$|j|jko"|j|jko"|j|jkS)N)rrr)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)rrrr)r�text�averagerrr�__str__2s

zStatistic.__str__cCsd|j|j|jfS)Nz)<Statistic traceback=%r size=%i count=%i>)rrr)rrrr�__repr__<szStatistic.__repr__cCs|j|j|jfS)N)rrr)rrrr�	_sort_key@szStatistic._sort_keyN)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrrrrrs
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"||_||_||_||_||_dS)N)rrr%rr&)rrrr%rr&rrrrKs
zStatisticDiff.__init__cCst|j|j|j|j|jf�S)N)rrrr%rr&)rrrrrRszStatisticDiff.__hash__cCs<|j|jko:|j|jko:|j|jko:|j|jko:|j|jkS)N)rrr%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)rrrr%rr&)rrrrrrr]s


zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>)rrr%rr&)rrrrriszStatisticDiff.__repr__cCs t|j�|jt|j�|j|jfS)N)rr%rr&rr)rrrrrnszStatisticDiff._sort_keyN)rr r!r"r#rrrrrrrrrrr$Dsr$cCs�g}xp|��D]d\}}|�|d�}|dk	rPt||j|j|j|j|j|j�}nt||j|j|j|j�}|�|�qWx6|��D]*\}}t|d|jd|j�}|�|�q�W|S)Nr)�items�popr$rr�append)�	old_group�	new_group�
statisticsr�statZpreviousrrr�_compare_grouped_statstsr.c@s\eZdZdZdZdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Framez
    Frame of a traceback.
    )�_framecCs
||_dS)N)r0)r�framerrrr�szFrame.__init__cCs
|jdS)Nr)r0)rrrr�filename�szFrame.filenamecCs
|jdS)N�)r0)rrrr�lineno�szFrame.linenocCs|j|jkS)N)r0)rrrrrr�szFrame.__eq__cCs|j|jkS)N)r0)rrrrr�__lt__�szFrame.__lt__cCs
t|j�S)N)rr0)rrrrr�szFrame.__hash__cCsd|j|jfS)Nz%s:%s)r2r4)rrrrr�sz
Frame.__str__cCsd|j|jfS)Nz<Frame filename=%r lineno=%r>)r2r4)rrrrr�szFrame.__repr__N)rr r!r"r#r�propertyr2r4rr5rrrrrrrr/�sr/c@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|��|_dS)N)rr�tuple�reversedr8)r�framesrrrr�s
zTraceback.__init__cCs
t|j�S)N)�lenr8)rrrr�__len__�szTraceback.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdS)N)r/)�.0�tracerrr�	<genexpr>�sz(Traceback.__getitem__.<locals>.<genexpr>)�
isinstance�slicer9r8r/)r�indexrrr�__getitem__�s
zTraceback.__getitem__cCs|j|jkS)N)r0r8)rr1rrr�__contains__�szTraceback.__contains__cCs
t|j�S)N)rr8)rrrrr�szTraceback.__hash__cCs|j|jkS)N)r8)rrrrrr�szTraceback.__eq__cCs|j|jkS)N)r8)rrrrrr5�szTraceback.__lt__cCst|d�S)Nr)�str)rrrrr�szTraceback.__str__cCsdt|�fS)Nz<Traceback %r>)r9)rrrrr�szTraceback.__repr__NFcCs�g}|dk	r2|dkr$||d�}q6|d|�}n|}|rBt|�}xH|D]@}|�d|j|jf�t�|j|j���}|rH|�d|�qHW|S)Nrz  File "%s", line %sz    %s)r:r)r2r4�	linecache�getline�strip)r�limitZmost_recent_first�linesZframe_slicer1�linerrr�format�s
zTraceback.format)NF)rr r!r"r#rr=rDrErrr5rrrMrrrrr7�sr7cCs 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)rr7)�objr;rrr�get_object_traceback�srOc@s`eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Tracez"
    Trace of a memory block.
    )�_tracecCs
||_dS)N)rQ)rr?rrrrszTrace.__init__cCs
|jdS)Nr)rQ)rrrr�domainszTrace.domaincCs
|jdS)Nr3)rQ)rrrrr	sz
Trace.sizecCst|jd�S)N�)r7rQ)rrrrr
szTrace.tracebackcCs|j|jkS)N)rQ)rrrrrrszTrace.__eq__cCs
t|j�S)N)rrQ)rrrrrszTrace.__hash__cCsd|jt|jd�fS)Nz%s: %sF)rrr)rrrrrsz
Trace.__str__cCsd|jt|jd�|jfS)Nz'<Trace domain=%s size=%s, traceback=%r>F)rRrrr)rrrrrszTrace.__repr__N)rr r!r"r#rr6rRrrrrrrrrrrrP�srPc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCst�|�||_dS)N)rr�_traces)r�tracesrrrr s
z_Traces.__init__cCs
t|j�S)N)r<rU)rrrrr=%sz_Traces.__len__cCs4t|t�r"tdd�|j|D��St|j|�SdS)Ncss|]}t|�VqdS)N)rP)r>r?rrrr@*sz&_Traces.__getitem__.<locals>.<genexpr>)rArBr9rUrP)rrCrrrrD(s
z_Traces.__getitem__cCs|j|jkS)N)rQrU)rr?rrrrE.sz_Traces.__contains__cCs|j|jkS)N)rU)rrrrrr1sz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)r<)rrrrr4sz_Traces.__repr__N)	rr r!rr=rDrErrrrrrrTsrTcCs&tj�|�}|�d�r"|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)r2rrr�_normalize_filename8s
r\c@seZdZdd�Zdd�ZdS)�
BaseFiltercCs
||_dS)N)�	inclusive)rr^rrrr@szBaseFilter.__init__cCst�dS)N)�NotImplementedError)rr?rrr�_matchCszBaseFilter._matchN)rr r!rr`rrrrr]?sr]csJeZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dS)N)�superrr^r\�_filename_patternr4�
all_framesrR)rr^�filename_patternr4rdrR)�	__class__rrrHs
zFilter.__init__cCs|jS)N)rc)rrrrreQszFilter.filename_patterncCs6t|�}t�||j�sdS|jdkr(dS||jkSdS)NFT)r\�fnmatchrcr4)rr2r4rrr�_match_frame_implUs
zFilter._match_frame_implcCs|�||�|jAS)N)rhr^)rr2r4rrr�_match_frame^szFilter._match_framecsH�jr,t�fdd�|D��r"�jS�jSn|d\}}��||�SdS)Nc3s|]\}}��||�VqdS)N)rh)r>r2r4)rrrr@csz*Filter._match_traceback.<locals>.<genexpr>r)rd�anyr^ri)rrr2r4r)rr�_match_tracebackas

zFilter._match_tracebackcCsD|\}}}|�|�}|jdk	r@|jr2|o0||jkS|p>||jkS|S)N)rkrRr^)rr?rRrrZresrrrr`ls


z
Filter._match)NFN)rr r!rr6rerhrirkr`�
__classcell__rr)rfrraGs	racs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dS)N)rbr�_domain)rr^rR)rfrrrxszDomainFilter.__init__cCs|jS)N)rn)rrrrrR|szDomainFilter.domaincCs|\}}}||jk|jAS)N)rRr^)rr?rRrrrrrr`�s
zDomainFilter._match)rr r!rr6rRr`rlrr)rfrrmwsrmc@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|�|_||_dS)N)rTrV�traceback_limit)rrVrprrrr�s
zSnapshot.__init__c	Cs*t|d��}t�||tj�WdQRXdS)z1
        Write the snapshot into a file.
        �wbN)�open�pickle�dumpZHIGHEST_PROTOCOL)rr2�fprrrrt�sz
Snapshot.dumpc	Cs t|d��}t�|�SQRXdS)z.
        Load a snapshot from a file.
        �rbN)rrrs�load)r2rurrrrw�sz
Snapshot.loadcs@|rt�fdd�|D��sdS|r<t�fdd�|D��r<dSdS)Nc3s|]}|���VqdS)N)r`)r>�trace_filter)r?rrr@�sz)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|���VqdS)N)r`)r>rx)r?rrr@�sT)rj)r�include_filters�exclude_filtersr?r)r?r�
_filter_trace�s

zSnapshot._filter_tracecs�t|t�stdt|�j��|rng�g�x(|D] }|jrD��|�q.��|�q.W���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?)rzryrrr�
<listcomp>�sz*Snapshot.filter_traces.<locals>.<listcomp>)rAr�	TypeError�typerr^r)rVrU�copyrorp)r�filtersrxZ
new_tracesr)rzryrr�
filter_traces�s

zSnapshot.filter_tracesc

Cs�|dkrtd|f��|r.|dkr.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)	N)rr2r4zunknown key_type: %r)r4r2z/cumulative mode cannot by used with key type %rrr4r3r)�
ValueErrorrVrU�KeyErrorr7rrr)
r�key_type�
cumulativeZstatsZ
tracebacksr?rRrZtrace_tracebackrr;r-r1rrr�	_group_by�sX



"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�Zgroupedr,rrrr,�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.
        T)r�r�)r�r.r�r$r)rZold_snapshotr�r�r+r*r,rrr�
compare_tos

zSnapshot.compare_toN)F)F)
rr r!r"rrt�staticmethodrwr{r�r�r,r�rrrrro�s3

rocCs$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_limitro)rVrprrr�
take_snapshot
s
r�)Zcollections.abcrr�	functoolsrrgrGZos.pathrXrsZ_tracemallocrrrrr$r.r/r7rOrPrTr\r]rarmror�rrrr�<module>s0&0#?%0