VcFcsddlmZmZddlmZddlZddlZddlZddl Z ddl Tddl m Z m Z dZ GddZGd d Zd ZeGd d ZeGddeZdZGddZGddeZdZGddZGddeZGddeZGddZdZdS))SequenceIterable)total_orderingN)Z*)_get_object_traceback _get_tracescsdD]a}t|dkr|dkr|r d||fzcSd||fzcSt|dks|dkr|r d||fzcSd ||fzcS|d z}bdS) N)BZKiBZMiBZGiBTiBidrz%+.1f %sz%.1f %si(rz%+.0f %sz%.0f %si)abs)sizeZsignZunit $/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 tracebackr countcs0||_||_||_dSNr)selfrr rs r __init__zStatistic.__init__%s"  r csDt|j|j|jfSr)hashrr rr r __hash__zStatistic.__hash__*sT^TY ;<<rrrr __repr__zStatistic.__repr__>s;>49dj9: ;r cs*|j|j|jfSr)r rrrrr _sort_keyzStatistic._sort_keyBs 4:t~66r N __name__ __module__ __qualname__ __slots__rrrr!r"r#r r rrsz/I ===///;;;77777r rcr) StatisticDiffrr size_diffr count_diffcsL||_||_||_||_||_dSrr+)rrr r,rr- r rzStatisticDiff.__init__Ms)" " $r cs\t|j|j|j|j|jfSr)rrr r,rr-rrr rzStatisticDiff.__hash__Ts.T^TYZ233 3r cst|tstS|j|jko?|j|jko/|j|jko|j|jko|j|jkSr)rr*rrr r,rr-rrr rzStatisticDiff.__eq__Xst%// "! !%/18I+8Neo58J%+-8Ou'77  9r csd|jt|jdt|jd|j|jfz}|jr%|j|jz }|dt|dzz }|S)Nz %s: size=%s (%s), count=%i (%+i)FTr)rr r r,rr-r r r r!zStatisticDiff.__str__asw2> 51155:? $$ : Bi$*,G N\'5%A%AA AD r csHd|j|j|j|j|jfzS)Nz9r+rrr r"zStatisticDiff.__repr__ms*K>49dn:t00 1r csvt|j|jt|j|j|jfSr)rr,r r-rrrrr r#zStatisticDiff._sort_keyrs3DN##TYDO$$dj  r Nr$r)r r r*r*Fs{JI%%%333999   111      r r*c sg}|D]\}}||d}|8t||j|j|jz |j|j|jz }n't||j|j|j|j}|||D]9\}}t|d|j d|j }||:|SNr)ZitemsZpopr*r rappend) old_group new_group statisticsrstatZpreviousr.r _compare_grouped_statsr5xs J$??,,    4==D11  9 !%DI ,E!%TZ(.-HJJDD!!%DI!%TZ99D $$??,,   4YDI:q4:+FF$ r csdeZdZ dZdZedZedZdZdZ dZ dZ d Z d S) Frame_framec||_dSrr7rframerr rzFrame.__init__s  r c|jdSr/r7rrr filenamezFrame.filename{1~r cr<Nr7rrr linenoz Frame.linenor>r cZt|tstS|j|jkSrrr6rr8rrr rz Frame.__eq__)%'' "! ! u|+,r cZt|tstS|j|jkSrrCrrr __lt__z Frame.__lt__s)%'' "! ! el*+r c*t|jSr)rr8rrr rzFrame.__hash__DK   r cs$|jd|jS)Nz:r=rArrr r!z Frame.__str__s---55r cs(d|jd|jdS)NzrIrrr r"zFrame.__repr__s26---MMr N) r%r&r'r(rpropertyr=rArrFrr!r"r)r r r6r6sIXX--- ,,, !!!666NNNNNr r6csjeZdZ dZddZedZdZdZdZ dZ d Z d Z d Z d ZddZdS) Traceback)_frames _total_nframeNcs~tj|tt||_||_dSr)rrtuplereversedrMrN)rframes total_nframer r rzTraceback.__init__s:$ Xf--.. )r c|jSr)rNrrr rRzTraceback.total_nframes !!r crGr)lenrMrrr __len__zTraceback.__len__4<   r ct|tr$td|j|DSt |j|S)Nc34K|]}t|VdSr)r6.0tracerr z(Traceback.__getitem__..(GG%uGGGGGGr )rslicerOrMr6rZindexrr __getitem__zTraceback.__getitem__M eU # # .GG4<3FGGGGG Ge,-- -r c|j|jvSr)r8rMr:rr __contains__zTraceback.__contains__|t|++r crGr)rrMrrr rzTraceback.__hash__sDL!!!r crBrrrLrrMrrr rzTraceback.__eq__s)%++ "! !  -.r crErrerrr rFzTraceback.__lt__s)%++ "! ! u},-r cs,t|dSr/)Zstrrrr r!zTraceback.__str__s47||r cs`dt|}|j|dz }n|d|jdz }|S)Nz r cr<r?rkrrr r z Trace.sizer>r cs.t|jddS)Ni)rLrlrrr rzTrace.traceback#s$+abb/**r crBr)rrjrrlrrr rz Trace.__eq__'rDr crGr)rrlrrr rzTrace.__hash__,rHr cs@|jdt|jdS)Nz: F)rr r rrr r!z Trace.__str__/s">>>< 5+I+I+IJJr csTd|jdt|jdd|jdS)Nz > > >P Qr N) r%r&r'r(rrKrnr rrrr!r"r)r r rjrjsI XX++X+--- !!!KKKQQQQQr rjcs2eZdZdZdZdZdZdZdZdS)_Tracescs<tj|||_dSr)rr_traces)rtracesrr rz_Traces.__init__8s$ r crGr)rTrprrr rUz_Traces.__len__=rVr crW)Nc3rXr)rjrYrr r\z&_Traces.__getitem__..Br]r )rr^rOrprjr_rr r`z_Traces.__getitem__@rar crbr)rlrprmrr rcz_Traces.__contains__Frdr crBr)rrorrprrr rz_Traces.__eq__Is)%)) "! !  -.r cs&dt|zS)Nz)rTrrr r"z_Traces.__repr__Ns 3t99,,r N) r%r&r'rrUr`rcrr"r)r r roro7sn !!!... ,,,/// -----r rocstj|}|dr |dd}|S)Nz.pyci)osZpathZnormcaseZendswith)r=rr _normalize_filenamersRs?w))H  !CRC= Or cseZdZdZdZdS) BaseFiltercr9r) inclusive)rrurr rzBaseFilter.__init__Zs "r cstr)ZNotImplementedErrorrmrr _matchzBaseFilter._match]s!!r N)r%r&r'rrvr)r r rtrtYs2###"""""r rtcsPeZdZ d fd ZedZdZdZdZdZ xZ S) FilterNFcst|||_t||_||_||_||_dSr)superrrurs_filename_patternrA all_framesrn)rrufilename_patternrArzrn __class__s r rzFilter.__init__bsL ###"!45E!F!F $ r crSr)ryrrr r{zFilter.filename_patternks %%r cst|}tj||jsdS|jdS||jkS)NFT)rsfnmatchryrArr=rAr r _match_frame_implzFilter._match_frame_implosG&x00x)?@@ 5 ; +4dk) *r cs@||||j z Sr)rrur~r r _match_framezFilter._match_framexs"%%h77t~;MNNr csjr*tfd|DrjSj S|d\}}||S)Nc3sJK|]\}}||VdSr)r)rZr=rAr r r\z*Filter._match_traceback..}sK66'x))(F;;666666r r)rzanyrur)rrr=rAs` r _match_tracebackzFilter._match_traceback{s| ? 76666+466666 ,~% N*+(| Hf$$Xv66 6r cs|\}}}}||}|j!|jr |o ||jkS|p ||jkS|Sr)rrnru)rr[rnr rrRZresrgr rvz Filter._matchs`05-i##I.. ; 6~ 66$+ 565v45 r )NFN) r%r&r'rrKr{rrrrv __classcell__r|@r rwrwas7;&&X&+++OOO 7 7 7r rwcs:eZdZfdZedZdZxZS) DomainFiltercsXt|||_dSr)rxr_domain)rrurnr|rr rzDomainFilter.__init__s& ### r crSr)rrrr rnzDomainFilter.domains |r cs8|\}}}}||jk|j z Sr)rnru)rr[rnr rrRr.r rvzDomainFilter._matchs'05-i$+%dn*<==r )r%r&r'rrKrnrvrrrr rrsbX>>>>>>>r rcsTeZdZ dZdZedZdZdZdZ d dZ d d Z d S) Snapshotcs<t||_||_dSr)rorqtraceback_limit)rrqrr r rzSnapshot.__init__sfoo .r cs t|d5}tj||tjddddS#1swxYwYdS)NZwb)openpickledumpZHIGHEST_PROTOCOL)rr=fpr r rz Snapshot.dumps (D ! ! ;R Kb&"9 : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s!AAAcs t|d5}tj|cdddS#1swxYwYdS)NZrb)rrload)r=rrr rz Snapshot.loads (D ! ! #R;r?? # # # # # # # # # # # # # # # # # #s 377cs|rtfd|DsdS|rtfd|DrdSdS)Nc3sBK|]}|VdSrrvrZ trace_filterr[ r r\)Snapshot._filter_trace..sE<<'$**511<<<<<z*Snapshot.filter_traces..sE888E!//0?05778%888r ) rrZ TypeErrorZtyper%rur0rqrpZcopyrr)rZfiltersrZ new_tracesrrs` @@r filter_traceszSnapshot.filter_tracess '8,, 6G"7mm4566 6  4 O O ' 9 9 )9#**<8888#**<8888888888T[-@888JJ ,1133J D$8999r cs>|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)rr=rAzunknown key_type: )rAr=z/cumulative mode cannot by used with key type %rrrAr@r)Z ValueErrorrqrpZKeyErrorrLr rr)rkey_type cumulativeZstatsZ tracebacksr[rnr Ztrace_tracebackrRrrQr4r;s 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 (E88FFFcs |||}t|}|dtj|SNT)ZreverseZkey)rZlistZvaluessortrr#)rrrZgroupedr3s r r3zSnapshot.statisticssR ..:66'..**++ )*=>>>r cs |||}|||}t||}|dtj|Sr)rr5rr*r#)rZ old_snapshotrrr2r1r3rgr compare_tozSnapshot.compare_tos_ NN8Z88  **8Z@@ +IyAA -*ABBBr N)F) r%r&r'rrZ staticmethodrrrrr3rr)r r rrs/// ;;;##\#   :::2111f      r rcs tstdt}t}t ||S)NzLthe tracemalloc module must be tracing memory allocations to take a snapshot)Z is_tracingZ RuntimeErrorrZget_traceback_limitr)rqrrr take_snapshotr'sP <<=<== = ]]F)++O FO , ,,r )Zcollections.abcrrZ functoolsrr}rfZos.pathrrrZ _tracemallocrrr rr*r5r6rLrirjrorsrtrwrrrr)r r rs........$$$$$$ ;;;;;;;;"%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