Jz`f6.dSrSSKrSSKrSSKrSSjr\R "5R5r\R\l \R\l \R\lS\R\R 'SrSrSrSrS rS rS rS rS rSrSrSrg!\a SrNf=f)aPython implementations of some algorithms for use by longobject.c. The goal is to provide asymptotically faster algorithms that can be used for operations on integers with many digits. In those cases, the performance overhead of the Python implementation is not significant since the asymptotic behavior is what dominates runtime. Functions provided by this module should be considered private and not part of any public API. Note: for ease of maintainability, please prefer clear code and avoid "micro-optimizations". This module will only be imported and used for integers with a huge number of digits. Saving a few microseconds with tricky or non-obvious code is not worth it. For people looking for maximum performance, they should use something like gmpy2.Nc[5n[5nU1nU(a{UR5nX;dX::aM#URU5 US- nURU5 URU5 US-(aURUS-5 U(aM{0nU(dU$[[ U55n [ U 5n U(a [ SU 5 X-X'U Hqn U S- U;a!U(a [ SU 5 XS- U-X'M-U S- nX- n U(a [ SU 5 XX-n X:waU(a [ S5 X-n XU 'Ms U$)Nzpow atz * base atz square atz and * base)setpopadditersortednextprint)wbase more_thanshowseenneedwsloditfirstthishisqs /usr/lib64/python3.13/_pylong.pycompute_powersr3s? 5D 5D B FFH 9   !V   r q5 FF26N " A  fTl B HE  h}AH !8q=k4(qkD(AGBBk4(Bx*+ dG'( Hrc ^^^^SSKJm SmUUUU4Sjm[R"[5 UR 5n[ UT"S5T5mUS:aSnU*nOSnT"X5nU(aU*nSSS5 U$!,(df  W$=f) z6Asymptotically fast conversion of an 'int' to Decimal.r)Decimalc|>UT::aT"U5$US- nX- nUSU-S- -nT"XB5T"X1U- 5TU--$Nr) nr w2rrBITLIMDinnerw2pows rr'int_to_decimal..innerysV ;Q4K !V W 17a- R}uRR059<<> B cp^^^UR5nUS:a[b[[U55$SmUUU4Sjm[ US-S-5n[ UST5mTR 5H up#X2-TU'M US:aU*nSnOS nT"X5nUSS :XaU(aURS 5nXE-$) z?Asymptotically fast conversion of an 'int' to a decimal string.iic>UT::a [U5$US- n[UTU5up4T"X1U- 5T"XB5RU5-$r!)strdivmodzfill)r#r r$rrDIGLIMr'pow10s rr'$int_to_decimal_string..innersQ ;q6M !V59%RR 5=#6#6r#:::rgyPD?rr-0)r._decimalr5r2intritemslstrip) r#r kvsignsr8r'r9s @@@rint_to_decimal_stringrGs A7{x+>!$%%F; A" "Q &'A 1a (E 6a1u B a Ats{q HHSM 8Orcp^^^^SmUUUU4Sjm[[T5ST5mT"S[T55$)z6Asymptotically fast conversion of a 'str' to an 'int'.ic~>X- T::a [TX5$X-S-S- nT"X!5T"X5TX- -X- --$r!)r@)abmidr8r'rFw5pows rr' _str_to_int_inner..innersW 5F?qv; uqyQc !ME!'N2!" #rr;r)rlen)rFr8r'rMs`@@@r_str_to_int_innerrPs9F## 3q61f -E CF rcXUR5RSS5n[U5$)zkAsymptotically fast version of PyLong_FromString(), conversion of a string of decimal digits into an 'int'._r=)rstripreplacerP)rFs rint_from_stringrUs'  3#A Q rc[R"SU5nU(d [S5e[UR S55nUR S5S:XaU*nU$)zBAsymptotically fast version of decimal string to 'int' conversion.z\s*([+-]?)([0-9_]+)\s*z&invalid literal for int() with base 10r*rr<)rematch ValueErrorrUgroup)rFmrDs r str_to_intr\sR *A.A ABB #AwwqzS B Hric(UR5U- [::a [X5$US-nU(aUS-nUS-nUS- nUS- nSU-S- nX- X-pv[X- X- U-XXt5up[XU-XXt5upU(aU S-n X-U -U 4$)a2Divide a 2n-bit nonnegative integer a by an n-bit positive integer b, using a recursive divide-and-conquer algorithm. Inputs: n is a positive integer b is a positive integer with exactly n bits a is a nonnegative integer such that a < 2**n * b Output: (q, r) such that a = b*q+r and 0 <= r < b. r)r. _DIV_LIMITr6_div3n2n) rJrKr#padhalf_nmaskb1b2q1rq2s r_div2n1nrhs ||~Z'a| a%C  a a Q !VF K1 D [!( QVakT11" EEB QD! 4EB  a <" a rcX- U:XaSU-S- XU-- U-pvO[XU5upgXu-U-Xd-- nUS:aUS-nXr- nUS:aMXg4$)zAHelper function for _div2n1n; not intended to be called directly.rr)rh)a12a3rKrcrdr#qrfs rr_r_sn x2~Q!|S!G_r11# "A a% Q  a% 4Krc^^^S/UR5T-S- T--mUUU4SjmU(aT"US[T55 T$)a2Decompose non-negative int a into base 2**n Input: a is a non-negative integer Output: List of the digits of a in base 2**n in little-endian order, meaning the most significant digit is last. The most significant digit is guaranteed to be non-zero. If a is 0 then the output is an empty list. rrcz>US-U:XaUTU'gX-S- nX1- T -nX- nXU-- nT"XaU5 T"XSU5 gr!r") xLRrLshiftupperlowera_digitsr'r#s rr'_int2digits..inner.sW q5A:HQK ulA  e^$ e e!r)r.rO)rJr#rur's `@@r _int2digitsrwsEsq||~)A-!34H   aCM" OrcN^^^UUU4SjmT(aT"S[T55$S$)zxCombine base-2**n digits into an int. This function is the inverse of `_int2digits`. For more details, see _int2digits. cd>US-U:XaTU$X-S- nX - T-nT"X!5U-T"X5-$r!r")rprqrLrrdigitsr'r#s rr'_digits2int..innerCsF q5A:!9 ulA c &%-77rr)rO)rzr#r's``@r _digits2intr|>s" 8%+5CK 11rcUR5n[X5nSn/n[U5H'n[XB-U-X5uptUR U5 M) UR 5 [ XR5nX4$)zWDivide a non-negative integer a by a positive integer b, giving quotient and remainder.r)r.rwreversedrhappendreverser|) rJrKr#rurfq_digitsa_digitq_digitrls r _divmod_posrMsw A1 H AHH%!qv0!7  ! H A 4KrcUS:Xa[eUS:a[U*U*5up#X#*4$US:a[U)U5up#U)X)-4$[X5$)zyAsymptotically fast replacement for divmod, for 'int'. Its time complexity is O(n**1.58), where n = #bits(a) + #bits(b). r)ZeroDivisionError int_divmodr)rJrKrlrfs rrr^se Av Q1"qb!"u Q1"a r1r6z1  r)F)__doc__rWr+r? ImportErrorr getcontextcopyr-MAX_PRECprecMAX_EMAXEmaxMIN_EMINEmintrapsInexactr2rGrPrUr\r^rhr_rwr|rrr"rrrs > B, \!++-224%..%..%..01W__-%N+Z6   "  < > 2" !W HsB$$B/.B/