%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/tracemalloc.cpython-38.pyc

U

naB@sddlmZmZddlmZddlZddlZddlZddl	Z	ddl
Tddl
mZmZddZ
Gdd	d	ZGd
ddZdd
ZeGdddZeGdddeZddZGdddZGdddeZddZGdddZGdddeZGdddeZGd d!d!Zd"d#ZdS)$)SequenceIterable)total_orderingN)*)_get_object_traceback_get_tracescCsdD]|}t|dkr@|dkr@|r0d||fSd||fSt|dksT|dkrx|rhd||fSd	||fS|d
}qdS)N)BZKiBZMiBZGiBTiBdrz%+.1f %sz%.1f %si(r	z%+.0f %sz%.0f %si)abs)sizesignZunitr'/usr/local/lib/python3.8/tracemalloc.py_format_size
src@sDeZdZdZdZddZddZddZd	d
ZddZ	d
dZ
dS)	StatisticzS
    Statistic difference on memory allocations between two Snapshot instance.
    	tracebackrcountcCs||_||_||_dSNr)selfrrrrrr__init__%szStatistic.__init__cCst|j|j|jfSr)hashrrrrrrr__hash__*szStatistic.__hash__cCs$|j|jko"|j|jko"|j|jkSrrrotherrrr__eq__-s


zStatistic.__eq__cCsBd|jt|jd|jf}|jr>|j|j}|dt|d7}|S)Nz%s: size=%s, count=%iF, average=%s)rrrrrtextZaveragerrr__str__2s
zStatistic.__str__cCsd|j|j|jfS)Nz)<Statistic traceback=%r size=%i count=%i>rrrrr__repr__<szStatistic.__repr__cCs|j|j|jfSr)rrrrrrr	_sort_key@szStatistic._sort_keyN__name__
__module____qualname____doc__	__slots__rrrr!r"r#rrrrrs
rc@sDeZdZdZdZddZddZddZd	d
ZddZ	d
dZ
dS)
StatisticDiffzd
    Statistic difference on memory allocations between an old and a new
    Snapshot instance.
    rr	size_diffr
count_diffcCs"||_||_||_||_||_dSrr+)rrrr,rr-rrrrKs
zStatisticDiff.__init__cCst|j|j|j|j|jfSr)rrrr,rr-rrrrrRszStatisticDiff.__hash__cCs<|j|jko:|j|jko:|j|jko:|j|jko:|j|jkSrr+rrrrrVs



zStatisticDiff.__eq__cCsPd|jt|jdt|jd|j|jf}|jrL|j|j}|dt|d7}|S)Nz %s: size=%s (%s), count=%i (%+i)FTr)rrrr,rr-rrrrr!]s

zStatisticDiff.__str__cCsd|j|j|j|j|jfS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>r+rrrrr"iszStatisticDiff.__repr__cCs t|j|jt|j|j|jfSr)rr,rr-rrrrrrr#ns
zStatisticDiff._sort_keyNr$rrrrr*Dsr*cCsg}|D]d\}}||d}|dk	rNt||j|j|j|j|j|j}nt||j|j|j|j}||q|D]*\}}t|d|jd|j}||qz|SNr)itemspopr*rrappend)	old_group	new_group
statisticsrstatZpreviousrrr_compare_grouped_statsts*

r6c@s\eZdZdZdZddZeddZeddZd	d
Z	ddZ
d
dZddZddZ
dS)Framez
    Frame of a traceback.
    _framecCs
||_dSrr8rframerrrrszFrame.__init__cCs
|jdSr.r8rrrrfilenameszFrame.filenamecCs
|jdSNr8rrrrlinenoszFrame.linenocCs|j|jkSrr8rrrrrszFrame.__eq__cCs|j|jkSrr8rrrr__lt__szFrame.__lt__cCs
t|jSr)rr9rrrrrszFrame.__hash__cCsd|j|jfS)Nz%s:%sr<r?rrrrr!sz
Frame.__str__cCsd|j|jfS)Nz<Frame filename=%r lineno=%r>rArrrrr"szFrame.__repr__N)r%r&r'r(r)rpropertyr<r?rr@rr!r"rrrrr7s

r7c@sfeZdZdZdZddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
dddZdS)	Tracebackz`
    Sequence of Frame instances sorted from the oldest frame
    to the most recent frame.
    _framescCst|tt||_dSr)rrtuplereversedrE)rframesrrrrs
zTraceback.__init__cCs
t|jSr)lenrErrrr__len__szTraceback.__len__cCs4t|tr"tdd|j|DSt|j|SdS)Ncss|]}t|VqdSr)r7.0tracerrr	<genexpr>sz(Traceback.__getitem__.<locals>.<genexpr>)
isinstanceslicerFrEr7rindexrrr__getitem__s
zTraceback.__getitem__cCs|j|jkSr)r9rEr:rrr__contains__szTraceback.__contains__cCs
t|jSr)rrErrrrrszTraceback.__hash__cCs|j|jkSrrDrrrrrszTraceback.__eq__cCs|j|jkSrrDrrrrr@szTraceback.__lt__cCst|dSr.)strrrrrr!szTraceback.__str__cCsdt|fS)Nz<Traceback %r>)rFrrrrr"szTraceback.__repr__NFcCsg}|dk	r2|dkr$||d}q6|d|}n|}|rBt|}|D]@}|d|j|jft|j|j}|rF|d|qF|S)Nrz  File "%s", line %sz    %s)rGr1r<r?	linecachegetlinestrip)rlimitZmost_recent_firstlinesZframe_slicer;linerrrformats 
zTraceback.format)NF)r%r&r'r(r)rrJrSrTrrr@r!r"r\rrrrrCsrCcCs 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)rrC)objrHrrrget_object_tracebacksr^c@s`eZdZdZdZddZeddZeddZed	d
Z	ddZ
d
dZddZddZ
dS)Tracez"
    Trace of a memory block.
    _tracecCs
||_dSrr`rrMrrrrszTrace.__init__cCs
|jdSr.r`rrrrdomainszTrace.domaincCs
|jdSr=r`rrrrr	sz
Trace.sizecCst|jdS)N)rCrarrrrr
szTrace.tracebackcCs|j|jkSrr`rrrrrszTrace.__eq__cCs
t|jSr)rrarrrrrszTrace.__hash__cCsd|jt|jdfS)Nz%s: %sF)rrrrrrrr!sz
Trace.__str__cCsd|jt|jd|jfS)Nz'<Trace domain=%s size=%s, traceback=%r>F)rcrrrrrrrr"szTrace.__repr__N)r%r&r'r(r)rrBrcrrrrr!r"rrrrr_s


r_c@s<eZdZddZddZddZddZd	d
ZddZd
S)_TracescCst|||_dSr)rr_traces)rtracesrrrr s
z_Traces.__init__cCs
t|jSr)rIrfrrrrrJ%sz_Traces.__len__cCs4t|tr"tdd|j|DSt|j|SdS)Ncss|]}t|VqdSr)r_rKrrrrN*sz&_Traces.__getitem__.<locals>.<genexpr>)rOrPrFrfr_rQrrrrS(s
z_Traces.__getitem__cCs|j|jkSr)rarfrbrrrrT.sz_Traces.__contains__cCs|j|jkSr)rfrrrrr1sz_Traces.__eq__cCsdt|S)Nz<Traces len=%s>)rIrrrrr"4sz_Traces.__repr__N)	r%r&r'rrJrSrTrr"rrrrresrecCs&tj|}|dr"|dd}|S)Nz.pyc)ospathnormcaseendswith)r<rrr_normalize_filename8s
rmc@seZdZddZddZdS)
BaseFiltercCs
||_dSr)	inclusive)rrorrrr@szBaseFilter.__init__cCstdSr)NotImplementedErrorrbrrr_matchCszBaseFilter._matchN)r%r&r'rrqrrrrrn?srncsJeZdZdfdd	ZeddZddZd	d
ZddZd
dZ	Z
S)FilterNFcs2t|||_t||_||_||_||_dSr)superrrorm_filename_patternr?
all_framesrc)rrofilename_patternr?rurc	__class__rrrHs
zFilter.__init__cCs|jSr)rtrrrrrvQszFilter.filename_patterncCs6t|}t||jsdS|jdkr(dS||jkSdS)NFT)rmfnmatchrtr?rr<r?rrr_match_frame_implUs
zFilter._match_frame_implcCs||||jASr)r{rorzrrr_match_frame^szFilter._match_framecsHjr,tfdd|Dr"jSjSn|d\}}||SdS)Nc3s|]\}}||VqdSr)r{)rLr<r?rrrrNcsz*Filter._match_traceback.<locals>.<genexpr>r)ruanyror|)rrr<r?rrr_match_tracebackas
zFilter._match_tracebackcCsD|\}}}||}|jdk	r@|jr2|o0||jkS|p>||jkS|Sr)r~rcro)rrMrcrrresrrrrqls


z
Filter._match)NFN)r%r&r'rrBrvr{r|r~rq
__classcell__rrrwrrrGs	
	rrcs0eZdZfddZeddZddZZS)DomainFiltercst|||_dSr)rsr_domain)rrorcrwrrrxszDomainFilter.__init__cCs|jSr)rrrrrrc|szDomainFilter.domaincCs|\}}}||jk|jASr)rcro)rrMrcrrrrrrqs
zDomainFilter._match)r%r&r'rrBrcrqrrrrwrrws
rc@sXeZdZdZddZddZeddZdd	Zd
dZ	dd
Z
dddZdddZdS)SnapshotzB
    Snapshot of traces of memory blocks allocated by Python.
    cCst||_||_dSr)rergtraceback_limit)rrgrrrrrs
zSnapshot.__init__c	Cs*t|d}t||tjW5QRXdS)z1
        Write the snapshot into a file.
        wbN)openpickledumpHIGHEST_PROTOCOL)rr<fprrrrsz
Snapshot.dumpc
Cs,t|d}t|W5QRSQRXdS)z.
        Load a snapshot from a file.
        rbN)rrload)r<rrrrrsz
Snapshot.loadcs@|rtfdd|DsdS|r<tfdd|Dr<dSdS)Nc3s|]}|VqdSrrqrLtrace_filterrMrrrNsz)Snapshot._filter_trace.<locals>.<genexpr>Fc3s|]}|VqdSrrrrrrrNsT)r})rinclude_filtersexclude_filtersrMrrr
_filter_traceszSnapshot._filter_tracecst|tstdt|j|rjgg|D] }|jrB|q,|q,fddjjD}njj	}t
|jS)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)rrKrrrrr
<listcomp>sz*Snapshot.filter_traces.<locals>.<listcomp>)rOr	TypeErrortyper%ror1rgrfcopyrr)rfiltersrZ
new_tracesrrr
filter_tracess
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~|dkr\|f}
n|ddff}
t|
}	|	||<YnXz(||	}|j|7_|jd7_Wn&tk
rt|	|d||	<YnXq(q|S)	N)rr<r?zunknown key_type: %r)r?r<z/cumulative mode cannot by used with key type %rrr?r>r)
ValueErrorrgrfKeyErrorrCrrr)
rkey_type
cumulativeZstatsZ
tracebacksrMrcrZtrace_tracebackrrHr5r;rrr	_group_bysZ


zSnapshot._group_byFcCs,|||}t|}|jdtjd|S)zd
        Group statistics by key_type. Return a sorted list of Statistic
        instances.
        Treversekey)rlistvaluessortrr#)rrrZgroupedr4rrrr4s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)rr6rr*r#)rZold_snapshotrrr3r2r4rrr
compare_tos

zSnapshot.compare_toN)F)F)
r%r&r'r(rrstaticmethodrrrrr4rrrrrrs
3

rcCs$tstdt}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)rgrrrr
take_snapshot
s
r)collections.abcrr	functoolsrryrVZos.pathrirZ_tracemallocrrrrr*r6r7rCr^r_rermrnrrrrrrrrr<module>s2&0"?%0	

Zerion Mini Shell 1.0