????

Your IP : 3.129.218.121


Current Path : /lib/python3.10/__pycache__/
Upload File :
Current File : //lib/python3.10/__pycache__/tracemalloc.cpython-310.pyc

o

�*�gF�@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)�B�KiB�MiB�GiB�TiB�drz%+.1f %sz%.1f %si(rz%+.0f %sz%.0f %si)�abs)�size�sign�unit�r�"/usr/lib/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)�selfrrrrrr�__init__%s
zStatistic.__init__cCst|j|j|jf�Sr)�hashrrr�rrrr�__hash__*�zStatistic.__hash__cCs2t|t�stS|j|jko|j|jko|j|jkSr)�
isinstancer�NotImplementedrrr�r�otherrrr�__eq__-s

�
�zStatistic.__eq__cCsBd|jt|jd�|jf}|jr|j|j}|dt|d�7}|S)Nz%s: size=%s, count=%iF�, average=%s)rrrr�r�text�averagerrr�__str__4s
��zStatistic.__str__cCsd|j|j|jfS)Nz)<Statistic traceback=%r size=%i count=%i>rrrrr�__repr__>s�zStatistic.__repr__cCs|j|j|jfSr)rrrrrrr�	_sort_keyB�zStatistic._sort_keyN��__name__�
__module__�__qualname__�__doc__�	__slots__rrr%r*r+r,rrrrrs
rc@r)�
StatisticDiffzd
    Statistic difference on memory allocations between an old and a new
    Snapshot instance.
    �rr�	size_diffr�
count_diffcCs"||_||_||_||_||_dSrr5)rrrr6rr7rrrrMs

zStatisticDiff.__init__cCst|j|j|j|j|jf�Sr)rrrr6rr7rrrrrTs�zStatisticDiff.__hash__cCsJt|t�stS|j|jko$|j|jko$|j|jko$|j|jko$|j|jkSr)r!r4r"rrr6rr7r#rrrr%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&)rrrr6rr7r'rrrr*as

��zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>r5rrrrr+ms
��zStatisticDiff.__repr__cCs t|j�|jt|j�|j|jfSr)rr6rr7rrrrrrr,rs�zStatisticDiff._sort_keyNr.rrrrr4Fs	r4cCs�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�popr4rr�append)�	old_group�	new_group�
statisticsr�stat�previousrrr�_compare_grouped_statsxs"��rAc@s\eZdZdZdZdd�Zedd��Zedd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Framez
    Frame of a traceback.
    ��_framecC�
||_dSrrC�r�framerrrr��
zFrame.__init__cC�
|jdSr8rCrrrr�filename�rHzFrame.filenamecCrI�N�rCrrrr�lineno�rHzFrame.linenocC�t|t�stS|j|jkSr�r!rBr"rDr#rrrr%��
zFrame.__eq__cC�t|t�stS|j|jkSrrOr#rrr�__lt__�rPzFrame.__lt__cC�
t|j�Sr)rrDrrrrr��
zFrame.__hash__cC�d|j|jfS)Nz%s:%s�rJrMrrrrr*�r-z
Frame.__str__cCrU)Nz<Frame filename=%r lineno=%r>rVrrrrr+�r-zFrame.__repr__N)r/r0r1r2r3r�propertyrJrMr%rRrr*r+rrrrrB�s

rBc@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�reversedrYrZ)r�frames�total_nframerrrr�s

zTraceback.__init__cC�|jSr)rZrrrrr^��zTraceback.total_nframecCrSr)�lenrYrrrr�__len__�rTzTraceback.__len__cC�0t|t�rtdd�|j|D��St|j|�S)Ncs��|]}t|�VqdSr)rB��.0�tracerrr�	<genexpr>���z(Traceback.__getitem__.<locals>.<genexpr>)r!�slicer[rYrB�r�indexrrr�__getitem__��
zTraceback.__getitem__cC�|j|jvSr)rDrYrFrrr�__contains__��zTraceback.__contains__cCrSr)rrYrrrrr�rTzTraceback.__hash__cCrNr�r!rXr"rYr#rrrr%�rPzTraceback.__eq__cCrQrrrr#rrrrR�rPzTraceback.__lt__cCst|d�Sr8)�strrrrrr*�rqzTraceback.__str__cCs:dt|���}|jdur|d7}|S|d|j�d�7}|S)Nz<Traceback �>z total_nframe=)r[rZr^)r�srrrr+�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)r\r;rJrM�	linecache�getline�strip)r�limit�most_recent_first�lines�frame_slicerG�linerrr�format�s"
��zTraceback.formatr)NF)r/r0r1r2r3rrWr^rbrmrprr%rRr*r+r~rrrrrX�s
	
rXcCst|�}|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)rrX)�objr]rrr�get_object_tracebacksr�c@s`eZdZdZdZdd�Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�Tracez"
    Trace of a memory block.
    ��_tracecCrErr��rrgrrrrs
zTrace.__init__cCrIr8r�rrrr�domainrHzTrace.domaincCrIrKr�rrrrrrHz
Trace.sizecCst|jdd��S)N�)rXr�rrrrr#szTrace.tracebackcCrNr)r!r�r"r�r#rrrr%'rPzTrace.__eq__cCrSr)rr�rrrrr,rTzTrace.__hash__cCsd|jt|jd�fS)Nz%s: %sF)rrrrrrrr*/sz
Trace.__str__cCsd|jt|jd�|jfS)Nz'<Trace domain=%s size=%s, traceback=%r>F)r�rrrrrrrr+2s�zTrace.__repr__N)r/r0r1r2r3rrWr�rrr%rr*r+rrrrr�s


r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�_TracescCst�|�||_dSr)rr�_traces)r�tracesrrrr8s

z_Traces.__init__cCrSr)rar�rrrrrb=rTz_Traces.__len__cCrc)Ncsrdr)r�rerrrrhBriz&_Traces.__getitem__.<locals>.<genexpr>)r!rjr[r�r�rkrrrrm@rnz_Traces.__getitem__cCror)r�r�r�rrrrpFrqz_Traces.__contains__cCrNr)r!r�r"r�r#rrrr%IrPz_Traces.__eq__cCsdt|�S)Nz<Traces len=%s>)rarrrrr+Nrqz_Traces.__repr__N)	r/r0r1rrbrmrpr%r+rrrrr�7sr�cCs&tj�|�}|�d�r|dd�}|S)Nz.pyc���)�os�path�normcase�endswith)rJrrr�_normalize_filenameRs
r�c@seZdZdd�Zdd�ZdS)�
BaseFiltercCrEr)�	inclusive)rr�rrrrZrTzBaseFilter.__init__cCst�r)�NotImplementedErrorr�rrr�_match]szBaseFilter._matchN)r/r0r1rr�rrrrr�Ysr�csLeZdZ	d�fdd�	Zedd��Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�FilterNFcs2t��|�||_t|�|_||_||_||_dSr)�superrr�r��_filename_patternrM�
all_framesr�)rr��filename_patternrMr�r���	__class__rrrbs

zFilter.__init__cCr_r)r�rrrrr�kr`zFilter.filename_patterncCs2t|�}t�||j�s
dS|jdurdS||jkS)NFT)r��fnmatchr�rM�rrJrMrrr�_match_frame_implos

zFilter._match_frame_implcCs|�||�|jASr)r�r�r�rrr�_match_framexr zFilter._match_framecsB�jrt�fdd�|D��r�jS�jS|d\}}��||�S)Nc3s �|]\}}��||�VqdSr)r�)rfrJrMrrrrh}s��z*Filter._match_traceback.<locals>.<genexpr>r)r��anyr�r�)rrrJrMrrr�_match_traceback{s�zFilter._match_tracebackcCsF|\}}}}|�|�}|jdur!|jr|o||jkS|p ||jkS|Sr)r�r�r�)rrgr�rrr^�resrrrr��s

z
Filter._match)NFN)r/r0r1rrWr�r�r�r�r��
__classcell__rrr�rr�as�	
	r�cs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�DomainFiltercst��|�||_dSr)r�r�_domain)rr�r�r�rrr�s
zDomainFilter.__init__cCr_r)r�rrrrr��r`zDomainFilter.domaincCs|\}}}}||jk|jASr)r�r�)rrgr�rrr^rrrr��szDomainFilter._match)r/r0r1rrWr�r�r�rrr�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�rrrr�s

zSnapshot.__init__cCs@t|d��}t�||tj�Wd�dS1swYdS)z1
        Write the snapshot into a file.
        �wbN)�open�pickle�dump�HIGHEST_PROTOCOL)rrJ�fprrrr��s"�z
Snapshot.dumpcCs8t|d��
}t�|�Wd�S1swYdS)z.
        Load a snapshot from a file.
        �rbN)r�r��load)rJr�rrrr��s$�z
Snapshot.loadcs@|rt�fdd�|D��sdS|rt�fdd�|D��rdSdS)Nc3s�|]}|���VqdSr�r��rf�trace_filter�rgrrrh�s��z)Snapshot._filter_trace.<locals>.<genexpr>Fc3s�|]	}|���VqdSrr�r�r�rrrh�s��T)r�)r�include_filters�exclude_filtersrgrr�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�re�r�r�rrr�
<listcomp>�s�
�z*Snapshot.filter_traces.<locals>.<listcomp>)r!r�	TypeError�typer/r�r;r�r��copyr�r�)r�filtersr��
new_tracesrr�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)rrJrMzunknown key_type: %r)rMrJz/cumulative mode cannot by used with key type %rrrMrLr)�
ValueErrorr�r��KeyErrorrXrrr)r�key_type�
cumulative�stats�
tracebacksrgr�r�trace_tracebackr^rr]r?rGrrr�	_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��groupedr>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.
        Tr�)r�rAr�r4r,)r�old_snapshotr�r�r=r<r>rrr�
compare_tos

zSnapshot.compare_toN)F)
r/r0r1r2rr��staticmethodr�r�r�r�r>r�rrrrr��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�RuntimeErrorr�get_traceback_limitr�)r�r�rrr�
take_snapshot's

r�)�collections.abcrr�	functoolsrr�rv�os.pathr�r��_tracemallocrrrrr4rArBrXr�r�r�r�r�r�r�r�r�rrrr�<module>s4(2&M'0	

Page not found | The NCLEX Doctor

Page not found!

Sorry, this page is not available...