QfF\ddlmZmZddlmZddlZddlZddlZddl Z ddl ddl m Z m Z dZ GddZGd d Zd ZeGd 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 2/opt/alt/python312/lib64/python3.12/tracemalloc.py _format_sizer sz1 t9s?ts{!T4L00 D$<// t9y DEM!T4L00 D$<//  2c6eZdZ dZdZdZdZdZdZdZ y) Statistic tracebackrcountc.||_||_||_yNr)selfrrrs r__init__zStatistic.__init__%s"  rcZt|j|j|jfSr)hashrrrrs r__hash__zStatistic.__hash__*s T^^TYY ;<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__ __slots__rr#r)r/r1r3rrrrs,/I =/;7rrc6eZdZ dZdZdZdZdZdZdZ y) StatisticDiffrr 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 AD rczd|j|j|j|j|jfzS)Nz9r<r"s rr1zStatisticDiff.__repr__ms4K>>499dnn::t00 1rct|j|jt|j|j|j fSr)rr=rr>rrr"s rr3zStatisticDiff._sort_keyrs7DNN#TYYDOO$djj  rNr4r9rrr;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|j d|j }|j |=|SNr)itemspopr;rrappend) old_group new_group statisticsrstatpreviouss r_compare_grouped_statsrOxsJ$??, 4==D1   !%DII ,E!%TZZ(..-HJD!!%DII!%TZZ9D $-%??, 4YDII:q4::+F$- rcVeZdZ dZdZedZedZdZdZ dZ dZ d Z y ) Frame_framec||_yrrRrframes rrzFrame.__init__s  rc |jdSrFrRr"s rfilenamezFrame.filename{{1~rc |jdSNrRr"s rlinenoz Frame.linenorYrc`t|tstS|j|jk(Srr%rQr&rSr's rr)z Frame.__eq__%%'! ! u||+,rc`t|tstS|j|jkSrr_r's r__lt__z Frame.__lt__s%%'! ! ell*+rc,t|jSr)r!rSr"s rr#zFrame.__hash__DKK  rc8|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/r1r9rrrQrQsUI- , !6NrrQcbeZdZ dZddZedZdZdZdZ dZ d Z d Z d Z d Zdd Zy) Traceback)_frames _total_nframeNcntj|tt||_||_yr)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|trtd|j|DSt |j|S)Nc32K|]}t|ywr)rQ.0traces r z(Traceback.__getitem__..G3F%u3F)r%slicerprmrQrindexs r __getitem__zTraceback.__getitem__: eU #G4<<3FGG Ge,- -rc2|j|jvSr)rSrmrUs r __contains__zTraceback.__contains__||t||++rc,t|jSr)r!rmr"s rr#zTraceback.__hash__sDLL!!rc`t|tstS|j|jk(Srr%rlr&rmr's rr)zTraceback.__eq__s%%+! !  -.rc`t|tstS|j|jkSrrr's rrbzTraceback.__lt__s%%+! ! u}},-rct|dSrF)strr"s rr/zTraceback.__str__s47|rcndt|}|j|dz }|S|d|jdz }|S)Nz $"3"3!4A6 6ArcRg}||dkDr|| d}n|d|}n|}|r t|}|D]|}|jd|jd|jt j |j|jj }|si|jd|z~|S)Nrz File "z", line z %s)rqrIrXr] linecachegetlinestrip)rlimitmost_recent_firstlines frame_slicerVlines rformatzTraceback.formats  qy"E67m "6El K ";/K E LL!NNELL: ;$$U^^U\\BHHJD X_- !  rr)NF)r5r6r7r8rrjrsrwrrr#r)rbr/r1rr9rrrlrlsT-I*""!. ,"/ . rrlc6 t|}| t|Syr)rrl)objrrs rget_object_tracebackrs'#3 'F   rc`eZdZ dZdZedZedZedZdZ dZ dZ d Z y ) Trace_tracec||_yrrrr}s rrzTrace.__init__s  rc |jdSrFrr"s rdomainz Trace.domainrYrc |jdSr[rr"s rrz Trace.sizerYrc,t|jddS)N)rlrr"s rrzTrace.traceback#s$++ab/**rc`t|tstS|j|jk(Sr)r%rr&rr's rr)z Trace.__eq__'r`rc,t|jSr)r!rr"s rr#zTrace.__hash__,rdrcL|jdt|jdS)Nz: F)rrrr"s rr/z Trace.__str__/s>>< 5+IJJrcjd|jdt|jdd|jdS)NzP QrN) r5r6r7r8rrjrrrr)r#r/r1r9rrrrseI ++- !KQrrc0eZdZdZdZdZdZdZdZy)_Tracesc<tj|||_yr)rr_traces)rtracess rrz_Traces.__init__8s$ rc,t|jSr)rvrr"s rrwz_Traces.__len__=rxrct|trtd|j|DSt |j|S)Nc32K|]}t|ywr)rr{s rr~z&_Traces.__getitem__..Brr)r%rrprrrs 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)rvr"s rr1z_Traces.__repr__Ns 3t9,,rN) r5r6r7rrwrrr)r1r9rrrr7s  !. ,/ -rrcptjj|}|jdr|dd}|S)Nz.pyc)ospathnormcaseendswith)rXs r_normalize_filenamerRs4ww)H CR= OrceZdZdZdZy) BaseFilterc||_yr) inclusive)rrs rrzBaseFilter.__init__Zs "rctr)NotImplementedErrorrs r_matchzBaseFilter._match]s!!rN)r5r6r7rrr9rrrrYs #"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]rrXr]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|rXr]rs rr~z*Filter._match_traceback..}s+6+4'x))(F;+4s"r)ranyrr)rrrXr]s` r_match_tracebackzFilter._match_traceback{sW ??6+466~~% NN*+(| Hf$$Xv6 6rc|\}}}}|j|}|j2|jr|xr||jk(S|xs||jk7S|Sr)rrr)rr}rrrrsress rrz Filter._matchs^05-i##I. ;; "~~6$++ 565v45 r)NFN) r5r6r7rrjrrrrr __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}rrrrss rrzDomainFilter._matchs+05-i$++%dnn*<==r)r5r6r7rrjrrrrs@rrrs!>rrcLeZdZ dZdZedZdZdZdZ d dZ d dZ y ) Snapshotc2t||_||_yr)rrtraceback_limit)rrrs rrzSnapshot.__init__sfo .rc t|d5}tj||tjdddy#1swYyxYw)Nwb)openpickledumpHIGHEST_PROTOCOL)rrXfps rrz Snapshot.dumps7 (D !R KKb&"9"9 :" ! !s &=Acr t|d5}tj|cdddS#1swYyxYw)Nrb)rrload)rXrs rrz Snapshot.loads1 (D !R;;r? # # ! !s-6cb|rtfd|Dsy|rtfd|Dryy)Nc3@K|]}|jywrrr| trace_filterr}s rr~z)Snapshot._filter_trace..s$<+:<$**51+:sFc3BK|]}|j ywrrrs rr~z)Snapshot._filter_trace..s'8'6|$**511'6sT)r)rinclude_filtersexclude_filtersr}s `r _filter_tracezSnapshot._filter_traces< <+:<< 8'688rc t|ts!tdt|jz|rqg}g}|D]1}|j r|j |!|j |3|jjDcgc]}|j|||r|}}n$|jjj}t||jScc}w)Nz)filters must be a list of filters, not %s) r%r TypeErrortyper5rrIrrrcopyrr)rfiltersrrrr} new_tracess r filter_traceszSnapshot.filter_tracess '8,G"7m4456 6  O O ' ))#**<8#**<8 !( .2[[-@-@8-@E!//0?057 -@J8 ,,113J D$8$899 8sC c&|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)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  > >xAB B (*@@02:;< < ,,>C;o| < *? ;IE +DII%IJJ!OJ!-N %,,>C;o|,E6$.u$5 I$Y/ T)  a --$ 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 |SNT)reversekey)r listvaluessortrr3)rrrgroupedrLs rrLzSnapshot.statisticssF ..:6'..*+ )*=*=>rc |j||}|j||}t||}|jdtj|Sr )r rOrr;r3)r old_snapshotrrrKrJrLs r compare_tozSnapshot.compare_tosS NN8Z8  **8Z@ +IyA -*A*ABrN)F) r5r6r7rr staticmethodrrrr rLrr9rrrrs?/ ;## :21f rrcn ts tdt}t}t ||S)NzLthe tracemalloc module must be tracing memory allocations to take a snapshot) is_tracing RuntimeErrorrget_traceback_limitr)rrs r take_snapshotr's< <<= = ]F)+O FO ,,r)collections.abcrr functoolsrrros.pathrr _tracemallocrrrrr;rOrQrlrrrrrrrrrr9rrrs.$ ;"%7%7P/ / d(#N#N#NLJJJZ $Q$QN-h-6""-Z-` >: >EEP -r