python (3.12.0)

(root)/
lib/
python3.12/
__pycache__/
tracemalloc.cpython-312.opt-1.pyc

ˑeF\ddlmZmZddlmZddlZddlZddlZddl	Z	ddl
ddl
mZmZdZ
GddZGd	d
ZdZeGdd
ZeGddeZdZGddZGddeZdZGddZGddeZGddeZGddZdZy))SequenceIterable)total_orderingN)*)_get_object_traceback_get_tracescdD]U}t|dkr|dk7r|r	d||fzcSd||fzcSt|dks|dk(r|r	d||fzcSd	||fzcS|d
z}Wy)N)BKiBMiBGiBTiBdr
z%+.1f %sz%.1f %si(rz%+.0f %sz%.0f %si)abs)sizesignunits   ?/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/tracemalloc.py_format_sizer
s1
t9s?ts{!T4L00 D$<//t9y DEM!T4L00 D$<//
c8eZdZdZdZdZdZdZdZdZ	dZ
y	)
	StatisticzS
    Statistic difference on memory allocations between two Snapshot instance.
    	tracebackrcountc.||_||_||_yNr)selfrrrs    r__init__zStatistic.__init__%s"	
rcZt|j|j|jfSr)hashrrrrs r__hash__zStatistic.__hash__*s T^^TYY

;<<rct|tstS|j|jk(xr4|j|jk(xr|j
|j
k(Sr)
isinstancerNotImplementedrrrrothers  r__eq__zStatistic.__eq__-sQ%+!!%//1.II+.JJ%++-	/rcd|jt|jd|jfz}|jr+|j|jz}|dt|dzz
}|S)Nz%s: size=%s, count=%iF, average=%s)rrrrrtextaverages   r__str__zStatistic.__str__4sc'NN E2JJ  ::ii$**,GN\'5%AAADrcNd|j|j|jfzS)Nz)<Statistic traceback=%r size=%i count=%i>rr"s r__repr__zStatistic.__repr__>s%;>>499djj9:	;rcH|j|j|jfSr)rrrr"s r	_sort_keyzStatistic._sort_keyBs		4::t~~66rN__name__
__module____qualname____doc__	__slots__rr#r)r/r1r3rrrrs,/I
=/;7rrc8eZdZdZdZdZdZdZdZdZ	dZ
y	)

StatisticDiffzd
    Statistic difference on memory allocations between an old and a new
    Snapshot instance.
    rr	size_diffr
count_diffcJ||_||_||_||_||_yrr=)rrrr>rr?s      rrzStatisticDiff.__init__Ms%"	"
$rct|j|j|j|j|j
fSr)r!rrr>rr?r"s rr#zStatisticDiff.__hash__Ts3T^^TYYZZ23	3rc8t|tstS|j|jk(xrj|j|jk(xrO|j
|j
k(xr4|j|jk(xr|j|jk(Sr)r%r<r&rrr>rr?r's  rr)zStatisticDiff.__eq__Xs%/!!%//18II+8NNeoo58JJ%++-8OOu'7'77		9rcd|jt|jdt|jd|j|j
fz}|jr+|j|jz}|dt|dzz
}|S)Nz %s: size=%s (%s), count=%i (%+i)FTr+)rrrr>rr?r,s   rr/zStatisticDiff.__str__asx2>>		515::??	$$::ii$**,GN\'5%AAADrczd|j|j|j|j|jfzS)Nz9<StatisticDiff traceback=%r size=%i (%+i) count=%i (%+i)>r=r"s rr1zStatisticDiff.__repr__ms4K>>499dnn::t00	1rct|j|jt|j|j|j
fSr)rr>rr?rrr"s rr3zStatisticDiff._sort_keyrs7DNN#TYYDOO$djj 	 rNr4r:rrr<r<Fs-JI%39
1
 rr<c	2g}|jD]\}}|j|d}|Rt||j|j|jz
|j|j|jz
}n7t||j|j|j|j}|j||jD];\}}t|d|jd|j}|j|=|SNr)itemspopr<rrappend)	old_group	new_group
statisticsrstatpreviouss      r_compare_grouped_statsrPxsJ$??,
 	4==D1 !%DII

,E!%TZZ(..-HJD!!%DII!%TZZ9D	$
 %??, 	4YDII:q4::+F$ rcXeZdZdZdZdZedZedZdZ	dZ
dZd	Zd
Z
y)Framez
    Frame of a traceback.
    _framec||_yrrSrframes  rrzFrame.__init__s	rc |jdSrGrSr"s rfilenamezFrame.filename{{1~rc |jdSNrSr"s rlinenozFrame.linenorZrc`t|tstS|j|jk(Srr%rRr&rTr's  rr)zFrame.__eq__%%'!!u||+,rc`t|tstS|j|jkSrr`r's  r__lt__zFrame.__lt__s%%'!!ell*+rc,t|jSr)r!rTr"s rr#zFrame.__hash__DKK  rc8|jd|jS)N:rYr^r"s rr/z
Frame.__str__s--55rc<d|jd|jdS)Nz<Frame filename=z lineno=>rhr"s rr1zFrame.__repr__s26--MMrN)r5r6r7r8r9rpropertyrYr^r)rcr#r/r1r:rrrRrRsUI-
,
!6NrrRcdeZdZdZdZddZedZdZdZ	dZ
d	Zd
ZdZ
dZd
ZddZy)	Tracebackz`
    Sequence of Frame instances sorted from the oldest frame
    to the most recent frame.
    )_frames
_total_nframeNcntj|tt||_||_yr)rrtuplereversedrnro)rframestotal_nframes   rrzTraceback.__init__s+$
Xf-.)rc|jSr)ror"s rrtzTraceback.total_nframes!!!rc,t|jSr)lenrnr"s r__len__zTraceback.__len__4<<  rct|trtd|j|DSt	|j|S)Nc32K|]}t|ywr)rR.0traces  r	<genexpr>z(Traceback.__getitem__.<locals>.<genexpr>G%uG)r%slicerqrnrRrindexs  r__getitem__zTraceback.__getitem__:eU#G4<<3FGGGe,--rc2|j|jvSr)rTrnrVs  r__contains__zTraceback.__contains__||t||++rc,t|jSr)r!rnr"s rr#zTraceback.__hash__sDLL!!rc`t|tstS|j|jk(Srr%rmr&rnr's  rr)zTraceback.__eq__s%%+!!

-.rc`t|tstS|j|jkSrrr's  rrczTraceback.__lt__s%%+!!u}},-rct|dSrG)strr"s rr/zTraceback.__str__s47|rcndt|}|j|dz
}|S|d|jdz
}|S)Nz<Traceback rjz total_nframe=)rqrort)rss  rr1zTraceback.__repr__sO%+'%
HA
>$"3"3!4A66ArcRg}||dkDr||d}n|d|}n|}|rt|}|D]|}|jd|jd|jt	j
|j|jj
}|si|jd|z~|S)Nrz  File "z", line z    %s)rrrJrYr^	linecachegetlinestrip)rlimitmost_recent_firstlinesframe_slicerWlines       rformatzTraceback.formatsqy"E67m"6ElK";/K 	.ELL!NNELL:
;$$U^^U\\BHHJDX_-	.rr)NF)r5r6r7r8r9rrkrtrxrrr#r)rcr/r1rr:rrrmrmsT-I*""!.,"/
.
rrmc4t|}|t|Sy)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)rrm)objrss  rget_object_tracebackrs"#3
'F
  rcbeZdZdZdZdZedZedZedZ	dZ
dZd	Zd
Z
y)Tracez"
    Trace of a memory block.
    _tracec||_yrrrr~s  rrzTrace.__init__src |jdSrGrr"s rdomainzTrace.domainrZrc |jdSr\rr"s rrz
Trace.sizerZrc,t|jddS)N)rmrr"s rrzTrace.traceback#s$++ab/**rc`t|tstS|j|jk(Sr)r%rr&rr's  rr)zTrace.__eq__'rarc,t|jSr)r!rr"s rr#zTrace.__hash__,rercL|jdt|jdS)Nz: F)rrrr"s rr/z
Trace.__str__/s>><		5+IJJrcjd|jdt|jdd|jdS)Nz<Trace domain=z size=Fz, traceback=rj)rrrrr"s rr1zTrace.__repr__2s(;;TYY >P	QrN)r5r6r7r8r9rrkrrrr)r#r/r1r:rrrrseI
++-
!KQrrc0eZdZdZdZdZdZdZdZy)_Tracesc<tj|||_yr)rr_traces)rtracess  rrz_Traces.__init__8s$rc,t|jSr)rwrr"s rrxz_Traces.__len__=ryrct|trtd|j|DSt	|j|S)Nc32K|]}t|ywr)rr|s  rrz&_Traces.__getitem__.<locals>.<genexpr>Brr)r%rrqrrrs  rrz_Traces.__getitem__@rrc2|j|jvSr)rrrs  rrz_Traces.__contains__Frrc`t|tstS|j|jk(Sr)r%rr&rr's  rr)z_Traces.__eq__Is%%)!!

-.rcdt|zS)Nz<Traces len=%s>)rwr"s rr1z_Traces.__repr__Ns 3t9,,rN)	r5r6r7rrxrrr)r1r:rrrr7s 
!.,/
-rrcptjj|}|jdr|dd}|S)Nz.pyc)ospathnormcaseendswith)rYs r_normalize_filenamerRs4ww)H CR=OrceZdZdZdZy)
BaseFilterc||_yr)	inclusive)rrs  rrzBaseFilter.__init__Zs	"rctr)NotImplementedErrorrs  r_matchzBaseFilter._match]s!!rN)r5r6r7rrr:rrrrYs#"rrcJeZdZ	dfd	ZedZdZdZdZdZ	xZ
S)Filterc|t||||_t||_||_||_||_yr)superrrr_filename_patternr^
all_framesr)rrfilename_patternr^rr	__class__s      rrzFilter.__init__bs:
#"!45E!F$rc|jSr)rr"s rrzFilter.filename_patternks%%%rct|}tj||jsy|jy||jk(S)NFT)rfnmatchrr^rrYr^s   r_match_frame_implzFilter._match_frame_implos?&x0x)?)?@;;dkk)*rcB|j|||jzSr)rrrs   r_match_framezFilter._match_framexs!%%h7t~~;MNNrcjr-tfd|DrjSjS|d\}}j||S)Nc3HK|]\}}j||ywr)r)r}rYr^rs   rrz*Filter._match_traceback.<locals>.<genexpr>}s*6'x))(F;6s"r)ranyrr)rrrYr^s`   r_match_tracebackzFilter._match_traceback{sW??6+466~~% NN*+(|Hf$$Xv66rc|\}}}}|j|}|j2|jr|xr||jk(S|xs||jk7S|Sr)rrr)rr~rrrrtress       rrz
Filter._matchs^05-i##I.;;"~~6$++ 565v45
r)NFN)r5r6r7rrkrrrrr
__classcell__rs@rrras47;&&+O	7rrc4eZdZfdZedZdZxZS)DomainFilterc2t||||_yr)rr_domain)rrrrs   rrzDomainFilter.__init__s
#rc|jSr)rr"s rrzDomainFilter.domains||rcJ|\}}}}||jk(|jzSr)rr)rr~rrrrts      rrzDomainFilter._matchs+05-i$++%dnn*<==r)r5r6r7rrkrrrrs@rrrs!>rrcNeZdZdZdZdZedZdZdZ	dZ
ddZdd	Zy
)SnapshotzB
    Snapshot of traces of memory blocks allocated by Python.
    c2t||_||_yr)rrtraceback_limit)rrrs   rrzSnapshot.__init__sfo.rct|d5}tj||tjdddy#1swYyxYw)z1
        Write the snapshot into a file.
        wbN)openpickledumpHIGHEST_PROTOCOL)rrYfps   rrz
Snapshot.dumps;(D
!	;RKKb&"9"9:	;	;	;s	&<Acpt|d5}tj|cdddS#1swYyxYw)z.
        Load a snapshot from a file.
        rbN)rrload)rYrs  rrz
Snapshot.loads0
(D
!	#R;;r?	#	#	#s,5cb|rtfd|Dsy|rtfd|Dryy)Nc3@K|]}|jywrrr}trace_filterr~s  rrz)Snapshot._filter_trace.<locals>.<genexpr>s$<'$**51<sFc3BK|]}|jywrrrs  rrz)Snapshot._filter_trace.<locals>.<genexpr>s'8#$**5118sT)r)rinclude_filtersexclude_filtersr~s   `r
_filter_tracezSnapshot._filter_traces<<+:<<8'688rct|ts!tdt|jz|rqg}g}|D]1}|j
r|j
|!|j
|3|jjDcgc]}|j|||r|}}n$|jjj}t||jScc}w)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 %s)
r%r	TypeErrortyper5rrJrrrcopyrr)rfiltersrrrr~
new_tracess       r
filter_traceszSnapshot.filter_tracess'8,G"7m4456
6 O O '
9))#**<8#**<8	
9
.2[[-@-@8E!//0?057 8J8
,,113J
D$8$899
8sCc&|dvrtd||r|dvrtd|zi}i}|sZ|jjD]?}|\}}}}		||}
	||
}|xj
|z
c_|xjdz
c_A|S|jjD]F}|\}}}}	|D]8}
	||
}
	||
}|xj
|z
c_|xjdz
c_:H|S#t$r1|dk(r|}n|dk(r|dd}n|dddff}t	|}
|
||<YwxYw#t$rt|
|d||
<YwxYw#t$r$|dk(r|
f}n|
ddff}t	|}
|
||
<YwxYw#t$rt|
|d||
<YwxYw)	N)rrYr^zunknown key_type: )r^rYz/cumulative mode cannot by used with key type %rrr^r]r)
ValueErrorrrKeyErrorrmrrr)rkey_type
cumulativestats
tracebacksr~rrtrace_tracebackrtrrsrNrWs              r	_group_byzSnapshot._group_bys >>xABB(*@@02:;<
<
,,
E>C;o|
< *? ;IE +DII%IJJ!OJ!
EN%,,
I>C;o|,IE6$.u$5	I$Y/		T)	

a
I
I$G <;.!0!X-!0!!4#21#5a#8!"<!> )& 1I2;J/< E'0D!'DE)$E$6#x/&+XF',Qxm%5F$-f$5	,5
5)
6$I+4Ya+Hi(IsHC(/D%-E3/E4(7D"!D"%EE*E10E14FFc|j||}t|j}|jdtj
|S)zd
        Group statistics by key_type. Return a sorted list of Statistic
        instances.
        Treversekey)r
listvaluessortrr3)rrrgroupedrMs     rrMzSnapshot.statisticssA
..:6'..*+
)*=*=>rc|j||}|j||}t||}|jdtj|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
rPrr<r3)rold_snapshotrrrLrKrMs       r
compare_tozSnapshot.compare_tosNNN8Z8	 **8Z@	+IyA
-*A*ABrN)F)
r5r6r7r8rrstaticmethodrrrr
rMrr:rrrrs?/;##	:21f
rrcltstdt}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RuntimeErrorrget_traceback_limitr)rrs  r
take_snapshotr's7<<=	=
]F)+OFO,,r)collections.abcrr	functoolsrrros.pathrr_tracemallocrrrrr<rPrRrmrrrrrrrrrr:rr<module>r s.$
;"%7%7P/ / d(#N#N#NLJJJZ$Q$QN-h-6""-Z-`>:>EEP	-r