Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_pylong.cpython-314.pyc126 linesDownload Raw Back to __pycache__
1+
2��i�n���Rt^RIt^RIt^RItRRRR/Rlt]P!4P4t]P]n3]P]n]P]n^]P]P &RtRtRt]P+R	4t^R4IHt]!]4tAR^/RltR
tRtRtRtRt Rt!Rt"Rt#Rt$R# ]dRtL�i;i)a�Python implementations of some algorithms for use by longobject.c.5The goal is to provide asymptotically faster algorithms that can be6used for operations on integers with many digits.  In those cases, the7performance overhead of the Python implementation is not significant8since the asymptotic behavior is what dominates runtime. Functions9provided by this module should be considered private and not part of any10public API.11 12Note: for ease of maintainability, please prefer clear code and avoid13"micro-optimizations".  This module will only be imported and used for14integers with a huge number of digits.  Saving a few microseconds with15tricky or non-obvious code is not worth it.  For people looking for16maximum performance, they should use something like gmpy2.N�need_hiF�showc�L�\4p\4pV0pV'd�VP4pW9gW8:dK&VPV4V^,	pW,17p	V'dT	MTp18VPV194VPV204W�8wgK~VPW21,224K�VP4p\4pV'dj\	V4pVPV4V^,	pW�8�gK5V^,23V9gKEW�9gKMVPV4VPV4KqV'gV'dQh/p
\
Wl,4F�pV^,	pW�,24p	V^,25V
9d-V'd\RRR7W�^,26,V,pM�W�9dfV'd\RRR7W�,W�,,pW�8wd5V'd\RRR7^V,^,V8XgQhW�,pMV'd\RRR7W,pV'd\RY�V9dRMR	4W�V&K�	WmP48:gQhV
P4V,27;p'dV'gQhVFpW�K	V
#)28�z* base�)�end�squarez * base�powz at�needed�extra)	�set�pop�add�copy�max�remove�sorted�print�keys)�w�base�	more_thanrr�seen�need�ws�lo�hi�which�candsr�d�n�result�excesss&&&$$            �Lib\_pylong.py�compute_powersr$9s����5�D��5�D�29��B�30��F�F�H���9���������
�!�V��
�V����2�������31���u�
�
�8��F�F�1�9��
�I�I�K�E��E�E�32���J��
���Q��
�!�V��
�>�a��c��.�2�?��I�I�b�M��I�I�b�M��%���33�A�
�D�L�
!��
�!�V��
�V���Q�3�!�8���h�B�'���s�V�d�]�F�
�W���h�B�'��U�Q�U�]�F��x���)��,��2�v��z�Q��&��������e��$��Y�F���%��T�	�H�w�?��!��1"�4�6�6�8��������D�� �v� ���w��A�����H�c�8aaaa�^RIHo^�oVVVV3Rlo\P!\4;_uu_4VP	4p\VS!^4S4oV^8dRpV)pMRpS!W4pV'dV)pRRR4V# +'giX#;i)z6Asymptotically fast conversion of an 'int' to Decimal.)�Decimalc��<�VS8:d	S!V4#V^,	pW,	pV^V,^,34,pS!WB4S!W1V,354SV,,,#�r�)	r r�w2rr�BITLIM�D�inner�w2pows	&&   ����r#r.�int_to_decimal.<locals>.inner�sV�����;��Q�4�K�
�!�V��
�W��
�1��7�a�-�
 ���R�}�u�R�R��0�5��9�<�<�<r%TFN)�decimalr'�localcontext�_unbounded_dec_context�36bit_lengthr$)r �nbits�negater!r,r-r.r/s&   @@@@r#�int_to_decimalr7�s����%�
�F�=�=�37�	�	�4�	5�	5�������u�a��d�F�3���q�5��F���A��F��q�����W�F�386��M�396�	5��M�s�AB�B	c�aaa�VP4pVR8�d\e\\V44#RoVVV3Rlo\	VR,^,4p\V^S4oSP
4Fwr#W2,SV&K	V^8dV)pRpMRpS!W4pV^,R8XdV'dVPR4pWE,#)z?Asymptotically fast conversion of an 'int' to a decimal string.i��i�c�<�VS8:d\V4#V^,	p\VSV,4wr4S!W1V,404S!WB4PV4,#r))�str�divmod�zfill)r rr+rr�DIGLIMr.�pow10s&&   ���r#r.�$int_to_decimal_string.<locals>.inner�sQ�����;��q�6�M�
�!�V����5��9�%����R�R�� �5��=�#6�#6�r�#:�:�:r%g�y�PD�?�-r�0)r4�_decimalr:r7�intr$�items�lstrip)	r r�k�v�sign�sr=r.r>s	&     @@@r#�int_to_decimal_stringrJ�s����	����A��7�{�x�+��>�!�$�%�%��F�;�	�A�"�"�Q�&�'�A��1�a��(�E����
����6��a����1�u�
�B������
�a��A���t�s�{�q�
�H�H�S�M���8�Or%c�paaaa�RoVVVV3Rlo\\S4^S4oS!^\S44#)z6Asymptotically fast conversion of a 'str' to an 'int'.ic��<�W,41S8:d\SW4#W,^,^,	pS!W!4S!W4SW,42,,W,43,,#r))rC)�a�b�midr=r.rI�w5pows&& ����r#r.� _str_to_int_inner.<locals>.inner�sW����5�F�?��q��v�;���u�q�y�Q����c�
��!�M�E�!�'�N�2���!�"�	#r%)r$�len)rIr=r.rPsf@@@r#�_str_to_int_innerrS�s9����F�#�#�
�3�q�6�1�f�-�E���C��F��r%z0x1.a934f0979a371p-2)�defaultdict�GUARDc	�xaaaa
aa�Ro\Pp\4oS^8�gQhVVVV
VV3Rlo
VP4pV\,p\V4pV^,WE,44R8�,pVP
4^.8�d\RVR24h\P!\4;_uu_4oV!R4p\WgSRR7o\V^V,SRR7p^SP\P&\PSnSP4F6wr�V45P!4S,^,SnW�V	,53SV	&K8	?\P$SnS
!V!V4V4RRR4\46P'S4# +'giL%;i)	i��c�<�VS478:d5SP\\V44PV44R#V^,	pW,48pST,wrg\TP
4TP
4,49^4S,SnT5T5,p\PSnTP4pYT,,50pT^8�gQh^pYV8�d1^pYV,pT^,
pYV8�dRp\	YV4wr�YI,
p\T;;,^,
uu&S
!YB4?S
!YS4R#)Ni�)�extendrCr:�to_bytesr;r�adjusted�precr1�MAX_PREC�to_integral_value�_spread)r r�w1r+rr�p256�recip�count�hi2�BYTELIMrU�ctxr.�pow256r!s&&        ������r#r.�$_dec_str_to_int_inner.<locals>.inners�����<�
�M�M�#�c�!�f�+�.�.�q�1�2��
�!�V��
�V���!��*�K�D�51�1�:�:�<�$�-�-�/�9�1�=��E�C�H���u�f��B��'�'�C�H��%�%�'�B��$�Y��B���7�N�7��E��z����52���a����:�53 �E�$�R�.�G�C��I�B��E�N�a��N�	�b�
��
�b�
r%g�������?zcannot convert string of len z to int�T)rN)r1r'�	bytearray�__len__�_LOG_10_BASE_256rCr4�54ValueErrorr2r3r$�traps�Inexact�55ROUND_DOWN�roundingrDrZr[r\�56from_bytes)rIrUr-�lenS�log_ub�
log_ub_as_intr�D256�rpow256rFrGrdrer.rfr!s&d         @@@@@r#�_dec_str_to_int_innerrwsh����G����A�
�[�F��1�9��9�7�7�L
�9�9�;�D�
�$�
$�F���K�M����V�3�c�9�:�A�57	�|�|�~����8���g�F�G�G�	�	�	�4�	5�	5����v�����$�?�� ��A��H�g�t�D��&'��	�	�'�/�/�"��)�)����L�L�N�D�A��z�z�|�e�+�a�/�C�H��A�J�;��F�1�I�#�
��#�#���
�a��d�A��-586�.�>�>�&�!�!�/596�	5�s
�>CF)�)F9	c��VP4PRR4p\p\V4R8�d\e\60pV!V4#)zkAsymptotically fast version of PyLong_FromString(), conversion61of a string of decimal digits into an 'int'.�_ri��)�rstrip�replacerSrRrBrw)rI�funcs& r#�int_from_stringr}�s@��	62���63���3��#�A��D�64�1�v���x�3�$����7�Nr%c���\P!RV4pV'g\R4h\VP	^44pVP	^4R8XdV)pV#)zBAsymptotically fast version of decimal string to 'int' conversion.z\s*([+-]?)([0-9_]+)\s*z&invalid literal for int() with base 10r@)�re�matchrlr}�group)rI�mrGs&  r#�65str_to_intr��sR��	���*�A�.�A���A�B�B������66�#�A��w�w�q�z�S��
�B���Hr%i�c��VP4V,67\8:d\W4#V^,pV'dV^,pV^,pV^,
pV^,	p^V,^,68pW,	W,rv\W,	W,	V,WWt4wr�\W�V,WWt4wr�V'd69V	^,p	W�,V70,V	3#)a2Divide a 2n-bit nonnegative integer a by an n-bit positive integer71b, using a recursive divide-and-conquer algorithm.72 73Inputs:74  n is a positive integer75  b is a positive integer with exactly n bits76  a is a nonnegative integer such that a < 2**n * b77 78Output:79  (q, r) such that a = b*q+r and 0 <= r < b.80 81)r4�82_DIV_LIMITr;�_div3n2n)rMrNr �pad�half_n�mask�b1�b2�q1�r�q2s&&&        r#�_div2n1nr��s���	�|�|�~���Z�'��a�|��83�a�%�C�84�	�a���	�a���	�Q���
�!�V�F�
��K�1��D�
�[�!�(���Q�V�a�k�T�1�1�"�E�E�B��Q�D��!��4�E�B�85�	�a���
�<�"��a��r%c���W,	V8Xd'^V,^,86WV,,87V,rvM\WV4wrgWu,V,Wd,,88pV^8dV^,pWr,
pKWg3#)zAHelper function for _div2n1n; not intended to be called directly.)r�)�a12�a3rNr�r�r �qr�s&&&&&&  r#r�r��sc��89�x�2�~��Q��!�|�S�!�G�_�r�1�1����#���	90��"�����A�91�a�%�	�Q���	����4�Kr%c�aaa�^.VP4S,^,92S,,oVVV3RloV'dS!V^\S44S#)a2Decompose non-negative int a into base 2**n93 94Input:95  a is a non-negative integer96 97Output:98  List of the digits of a in base 2**n in little-endian order,99  meaning the most significant digit is last. The most100  significant digit is guaranteed to be non-zero.101  If a is 0 then the output is an empty list.102 103c��<�V^,V8XdVSV&R#W,^,	pW1,104S	,pW,	pWV,,pS!WaV4S!WSV4R#)rNr*)105�x�L�RrO�shift�upper�lower�a_digitsr.r s106&&&    ���r#r.�_int2digits.<locals>.inner�sW����q�5�A�:��H�Q�K���u��l����A�
���107���e�^�$��
�e���
�e�!�r%)r4rR)rMr r�r.s&f@@r#�_int2digitsr��sE����s�q�|�|�~��)�A�-�!�3�4�H�	�	�
�a��C��M�"��Or%c�Paaa�VVV3RloS'dS!^\S44#^#)zxCombine base-2**n digits into an int. This function is the108inverse of `_int2digits`. For more details, see _int2digits.109c�<�V^,V8Xd110SV,#W,^,	pW ,111S,pS!W!4V,S!W4,#r)r*)r�r�rOr��digitsr.r s&&  ���r#r.�_digits2int.<locals>.inner�sF����q�5�A�:��!�9���u��l����A�
���c�
��&�%��-�7�7r%)rR)r�r r.sff@r#�_digits2intr��s"���1128�%+�5��C��K� �1��1r%c���VP4p\W4p^p.p\V4F/p\WB,V,W4wrtVP	V4K1	VP4\
WR4pW�3#)zWDivide a non-negative integer a by a positive integer b, giving113quotient and remainder.)r4r��reversedr��append�reverser�)	rMrNr r�r��q_digits�a_digit�q_digitr�s	&&       r#�_divmod_posr��sr��	114����A��1� �H�	�A��H��H�%���q�v��0�!�7�115������ �&�
�����H� �A��4�Kr%c��V^8Xd\R4hV^8d\V)V)4wr#W#)3#V^8d\V(V4wr#V(W(,3#\W4#)zyAsymptotically fast replacement for divmod, for 'int'.116Its time complexity is O(n**1.58), where n = #bits(a) + #bits(b).117zdivision by zero)�ZeroDivisionError�118int_divmodr�)rMrNr�r�s&&  r#r�r�sk��	�A�v�� 2�3�3�	119�Q���1�"�q�b�!����"�u��	120�Q���1�"�a� ����r�1�r�6�z���1� � r%),�__doc__rr1rB�ImportErrorr$�121getcontextrr3r\r[�MAX_EMAX�Emax�MIN_EMIN�Eminrmrnr7rJrS�float�fromhexrk�collectionsrTrCr^rwr}r�r�r�r�r�r�r�r��consumer�	itertools�chainr�limit�rangerr*r%r#�<module>r�s��>�122����NJ
�%�J
�e�J
�X!�+�+�-�2�2�4��%�.�.���%�.�.���%�.�.���01����W�_�_�-�%�N+�Z�J�=�=�!7�8��$�123�c�124���t"�a�t"�l�	
�"�125� �<126��>2��"
!�b��]���H��s�C�	C�C
codekingpro/portable-devtools · Team Ai