VcFddlmZmZddlmZddlZddlZddlZddl Z ddl Tddl m Z m Z dZ GddZGd d Zd ZeGd d ZeGddeZdZGddZGddeZdZGddZGddeZGddeZGddZdZdS))SequenceIterable)total_orderingN)*)_get_object_traceback _get_tracescdD]a}t|dkr|dkr|r d||fzcSd||fzcSt|dks|dkr|r d||fzcSd ||fzcS|d z}bdS) N)BKiBMiBGiBTiBdr z%+.1f %sz%.1f %si(rz%+.0f %sz%.0f %si)abs)sizesignunits $/usr/lib64/python3.11/tracemalloc.py _format_sizer s1   t99s? 0ts{ 0 0!T4L0000 D$<//// t99y  0DEM 0 0!T4L0000 D$<////    c8eZdZ dZdZdZdZdZdZdZ dS) Statistic tracebackrcountc0||_||_||_dSNr)selfrrrs r__init__zStatistic.__init__%s"  rcDt|j|j|jfSr)hashrrrrs r__hash__zStatistic.__hash__*sT^TY ;<<rr"s r__repr__zStatistic.__repr__>s;>49dj9: ;rc*|j|j|jfSr)rrrr"s r _sort_keyzStatistic._sort_keyBs 4:t~66rN __name__ __module__ __qualname__ __slots__rr#r)r/r1r3rrrrsz/I ===///;;;77777rrc8eZdZ dZdZdZdZdZdZdZ dS) StatisticDiffrr size_diffr count_diffcL||_||_||_||_||_dSrr<)rrrr=rr>s rrzStatisticDiff.__init__Ms)" " $rc\t|j|j|j|j|jfSr)r!rrr=rr>r"s rr#zStatisticDiff.__hash__Ts.T^TYZ233 3rct|tstS|j|jko?|j|jko/|j|jko|j|jko|j|jkSr)r%r;r&rrr=rr>r's rr)zStatisticDiff.__eq__Xst%// "! !%/18I+8Neo58J%+-8Ou'77  9rcd|jt|jdt|jd|j|jfz}|jr%|j|jz }|dt|dzz }|S)Nz %s: size=%s (%s), count=%i (%+i)FTr+)rrrr=rr>r,s rr/zStatisticDiff.__str__asw2> 51155:? $$ : Bi$*,G N\'5%A%AA AD rcHd|j|j|j|j|jfzS)Nz9r<r"s rr1zStatisticDiff.__repr__ms*K>49dn:t00 1rcvt|j|jt|j|j|jfSr)rr=rr>rrr"s rr3zStatisticDiff._sort_keyrs3DN##TYDO$$dj  rNr4r9rrr;r;Fs{JI%%%333999   111      rr;c g}|D]\}}||d}|8t||j|j|jz |j|j|jz }n't||j|j|j|j}|||D]9\}}t|d|j d|j }||:|SNr)itemspopr;rrappend) old_group new_group statisticsrstatpreviouss r_compare_grouped_statsrOxs J$??,,    4==D11  9 !%DI ,E!%TZ(.-HJJDD!!%DI!%TZ99D $$??,,   4YDI:q4:+FF$ rcdeZdZ dZdZedZedZdZdZ dZ dZ d Z d S) Frame_framec||_dSrrRrframes rrzFrame.__init__s  rc|jdSrFrRr"s rfilenamezFrame.filename{1~rc|jdSNrRr"s rlinenoz Frame.linenorYrcZt|tstS|j|jkSrr%rQr&rSr's rr)z Frame.__eq__)%'' "! ! u|+,rcZt|tstS|j|jkSrr_r's r__lt__z Frame.__lt__s)%'' "! ! el*+rc*t|jSr)r!rSr"s rr#zFrame.__hash__DK   rc$|jd|jS)N:rXr]r"s rr/z Frame.__str__s---55rc(d|jd|jdS)Nzrgr"s rr1zFrame.__repr__s26---MMrN) r5r6r7r8rpropertyrXr]r)rbr#r/r1r9rrrQrQsIXX--- ,,, !!!666NNNNNrrQcjeZdZ dZddZedZdZdZdZ dZ d Z d Z d Z d ZddZdS) Traceback)_frames _total_nframeNc~tj|tt||_||_dSr)rrtuplereversedrmrn)rframes total_nframes rrzTraceback.__init__s:$ Xf--.. )rc|jSr)rnr"s rrszTraceback.total_nframes !!rc*t|jSr)lenrmr"s r__len__zTraceback.__len__4<   rct|tr$td|j|DSt |j|S)Nc34K|]}t|VdSr)rQ.0traces r z(Traceback.__getitem__..(GG%uGGGGGGr)r%slicerprmrQrindexs r __getitem__zTraceback.__getitem__M eU # # .GG4<3FGGGGG Ge,-- -rc|j|jvSr)rSrmrUs r __contains__zTraceback.__contains__|t|++rc*t|jSr)r!rmr"s rr#zTraceback.__hash__sDL!!!rcZt|tstS|j|jkSrr%rlr&rmr's rr)zTraceback.__eq__s)%++ "! !  -.rcZt|tstS|j|jkSrrr's rrbzTraceback.__lt__s)%++ "! ! u},-rc,t|dSrF)strr"s rr/zTraceback.__str__s47||rc`dt|}|j|dz }n|d|jdz }|S)Nz >>< 5+I+I+IJJrcTd|jdt|jdd|jdS)Nz > > >P QrN) r5r6r7r8rrjrrrr)r#r/r1r9rrrrsI XX++X+--- !!!KKKQQQQQrrc2eZdZdZdZdZdZdZdZdS)_Tracesc<tj|||_dSr)rr_traces)rtracess rrz_Traces.__init__8s$ rc*t|jSr)rvrr"s rrwz_Traces.__len__=rxrct|tr$td|j|DSt |j|S)Nc34K|]}t|VdSr)rr{s rr~z&_Traces.__getitem__..Brr)r%rrprrrs rrz_Traces.__getitem__@rrc|j|jvSr)rrrs rrz_Traces.__contains__FrrcZt|tstS|j|jkSr)r%rr&rr's rr)z_Traces.__eq__Is)%)) "! !  -.rc&dt|zS)Nz)rvr"s rr1z_Traces.__repr__Ns 3t99,,rN) r5r6r7rrwrrr)r1r9rrrr7sn !!!... ,,,/// -----rrctj|}|dr |dd}|S)Nz.pyc)ospathnormcaseendswith)rXs r_normalize_filenamerRs?w))H  !CRC= OrceZdZdZdZdS) BaseFilterc||_dSr) inclusive)rrs rrzBaseFilter.__init__Zs "rctr)NotImplementedErrorrs r_matchzBaseFilter._match]s!!rN)r5r6r7rrr9rrrrYs2###"""""rrcPeZdZ d fd ZedZdZdZdZdZ xZ S) FilterNFct|||_t||_||_||_||_dSr)superrrr_filename_patternr] all_framesr)rrfilename_patternr]rr __class__s rrzFilter.__init__bsL ###"!45E!F!F $ rc|jSr)rr"s rrzFilter.filename_patternks %%rct|}tj||jsdS|jdS||jkS)NFT)rfnmatchrr]rrXr]s r_match_frame_implzFilter._match_frame_implosG&x00x)?@@ 5 ; +4dk) *rc@||||j z Sr)rrrs r _match_framezFilter._match_framexs"%%h77t~;MNNrcjr*tfd|DrjSj S|d\}}||S)Nc3JK|]\}}||VdSr)r)r|rXr]rs rr~z*Filter._match_traceback..}sK66'x))(F;;666666rr)ranyrr)rrrXr]s` r_match_tracebackzFilter._match_traceback{s| ? 76666+466666 ,~% N*+(| Hf$$Xv66 6rc|\}}}}||}|j!|jr |o ||jkS|p ||jkS|Sr)rrr)rr}rrrrsress rrz Filter._matchs`05-i##I.. ; 6~ 66$+ 565v45 r)NFN) r5r6r7rrjrrrrr __classcell__rs@rrras7;&&X&+++OOO 7 7 7rrc:eZdZfdZedZdZxZS) DomainFiltercXt|||_dSr)rr_domain)rrrrs rrzDomainFilter.__init__s& ### rc|jSr)rr"s rrzDomainFilter.domains |rc8|\}}}}||jk|j z Sr)rr)rr}rrrrss rrzDomainFilter._matchs'05-i$+%dn*<==r)r5r6r7rrjrrrrs@rrrsbX>>>>>>>rrcTeZdZ dZdZedZdZdZdZ d dZ d d Z d S) Snapshotc<t||_||_dSr)rrtraceback_limit)rrrs rrzSnapshot.__init__sfoo .rc t|d5}tj||tjddddS#1swxYwYdS)Nwb)openpickledumpHIGHEST_PROTOCOL)rrXfps rrz Snapshot.dumps (D ! ! ;R Kb&"9 : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s!AAAc t|d5}tj|cdddS#1swxYwYdS)Nrb)rrload)rXrs rrz Snapshot.loads (D ! ! #R;r?? # # # # # # # # # # # # # # # # # #s 377c|rtfd|DsdS|rtfd|DrdSdS)Nc3BK|]}|VdSrrr| trace_filterr}s rr~z)Snapshot._filter_trace..sE<<'$**511<<<<<.sH88#$**5111888888rT)r)rinclude_filtersexclude_filtersr}s `r _filter_tracezSnapshot._filter_traces  <<<<+:<<<<< u  8888'688888 utrc t|ts$tdt|jz|rVgg|D]4}|jr||5fdjjD}njj }t|j S)Nz)filters must be a list of filters, not %scBg|]}||Sr9)r)r|r}rrrs r z*Snapshot.filter_traces..sE888E!//0?05778%888r) r%r TypeErrortyper5rrIrrcopyrr)rfiltersr new_tracesrrs` @@r filter_traceszSnapshot.filter_tracess '8,, 6G"7mm4566 6  4 O O ' 9 9 )9#**<8888#**<8888888888T[-@888JJ ,1133J D$8999rc>|dvrtd||r|dvrtd|zi}i}|s|jjD]}|\}}}} ||} nO#t$rB|dkr|} n"|dkr |dd} n|dddff} t | } | ||<YnwxYw || } | xj|z c_| xjdz c_#t$rt| |d|| <YwxYwn|jjD]}|\}}}} |D]} || } n9#t$r,|dkr| f} n | ddff} t | } | || <YnwxYw || } | xj|z c_| xjdz c_o#t$rt| |d|| <YwxYw|S) N)rrXr]zunknown key_type: )r]rXz/cumulative mode cannot by used with key type %rrr]r\r) ValueErrorrrKeyErrorrlrrr)rkey_type cumulativestats tracebacksr}rrtrace_tracebackrsrrrrMrVs r _group_byzSnapshot._group_bys > > C*xxABB B  <(*@@ <02:;<< < ' I, E E>C;o| < *? ;II<<<;.?!0!X-?!0!!4#21#5a#8!" )& 1 1I2;J///<E +DII%IIJJ!OJJJEEE'0D!'D'DE)$$$E# E*, I I>C;o|,IIE6$.u$5 #666#x/6&+XFF',Qxm%5F$-f$5$5 ,5 5))) 6I$Y/ T)  a #III+4Ya+H+Hi(((II  sI AA B B $(C  C.-C. D3E  E (E88FFFc |||}t|}|dtj|SNT)reversekey)r listvaluessortrr3)rrrgroupedrLs rrLzSnapshot.statisticssR ..:66'..**++ )*=>>>rc |||}|||}t||}|dtj|Sr )r rOrr;r3)r old_snapshotrrrKrJrLs r compare_tozSnapshot.compare_tos_ NN8Z88  **8Z@@ +IyAA -*ABBBrN)F) r5r6r7rr staticmethodrrrr rLrr9rrrrs/// ;;;##\#   :::2111f      rrc tstdt}t}t ||S)NzLthe tracemalloc module must be tracing memory allocations to take a snapshot) is_tracing RuntimeErrorrget_traceback_limitr)rrs r take_snapshotr'sP <<=<== = ]]F)++O FO , ,,r)collections.abcrr functoolsrrros.pathrr _tracemallocrrrrr;rOrQrlrrrrrrrrrr9rrr s........$$$$$$ ;;;;;;;;"%7%7%7%7%7%7%7%7P/ / / / / / / / d(#N#N#N#N#N#N#N#NLJJJJJJJJZ   $Q$Q$Q$Q$Q$Q$Q$QN-----h---6""""""""-----Z---` > > > > >: > > >EEEEEEEEP - - - - -r