Ë
    òT•j³”  ã                   óÈ  — d Z ddlmZ ddlZddlZddlZddlZddlZddlZdgZ	ej                  j                  Zej                  j                  Z ej                  d¬«      d„ «       Z ej"                  dej$                  ej&                  z  «      Zdd	„Zd
„ Z ej"                  dej.                  ej$                  z  «      j0                  Z G d„ dej4                  «      Zy)z/Fraction, infinite-precision, rational numbers.é    ©ÚDecimalNÚFractioni @  )Úmaxsizec                 ó¶   — 	 t        |dt        «      }t        t        t        | «      «      |z  «      }| dk\  r|n| }|dk(  rdS |S # t        $ r	 t
        }Y Œ$w xY w)Néÿÿÿÿr   éþÿÿÿ)ÚpowÚ_PyHASH_MODULUSÚhashÚabsÚ
ValueErrorÚ_PyHASH_INF)Ú	numeratorÚdenominatorÚdinvÚhash_Úresults        ú /usr/lib/python3.12/fractions.pyÚ_hash_algorithmr      se   € ð2Ü�; ¤OÓ4ˆô( ”Tœ#˜i›.Ó)¨DÑ0Ó1ˆØ 1’n‰U¨5¨&€FØ˜2’ˆ2Ð) 6Ð)øô+ ò äŠðús   ‚A ÁAÁAa¶  
    \A\s*                                  # optional whitespace at the start,
    (?P<sign>[-+]?)                        # an optional sign, then
    (?=\d|\.\d)                            # lookahead for digit or .digit
    (?P<num>\d*|\d+(_\d+)*)                # numerator (possibly empty)
    (?:                                    # followed by
       (?:\s*/\s*(?P<denom>\d+(_\d+)*))?   # an optional denominator
    |                                      # or
       (?:\.(?P<decimal>\d*|\d+(_\d+)*))?  # an optional fractional part
       (?:E(?P<exp>[-+]?\d+(_\d+)*))?      # and optional exponent
    )
    \s*\Z                                  # and optional whitespace to finish
c                 ó°   — |dk\  r	|d|z  z  }n	| d| z  z  } t        | |dz	  z   |«      \  }}|dk(  r|dz  dk(  r|dz  }|r|dk  n| dk  }|t        |«      fS )aM  Round a rational number to the nearest multiple of a given power of 10.

    Rounds the rational number n/d to the nearest integer multiple of
    10**exponent, rounding to the nearest even integer multiple in the case of
    a tie. Returns a pair (sign: bool, significand: int) representing the
    rounded value (-1)**sign * significand * 10**exponent.

    If no_neg_zero is true, then the returned sign will always be False when
    the significand is zero. Otherwise, the sign reflects the sign of the
    input.

    d must be positive, but n and d need not be relatively prime.
    r   é
   é   r	   )Údivmodr   )ÚnÚdÚexponentÚno_neg_zeroÚqÚrÚsigns          r   Ú_round_to_exponentr"   J   s|   € ð �1‚}Ø	ˆR�‰\Ñ‰à	ˆR�(�‰]Ñˆô �!�q˜A‘v‘, Ó"�D€A€qØˆA‚v�!�a‘%˜1’*Ø	ˆR‰ˆáˆ1ˆqŠ5 Q¨¡U€DØ”�Q“ˆ<Ðó    c                 ó  — | dk(  rddd|z
  fS t        t        | «      «      t        |«      }}t        |«      t        |«      z
  ||k  z   }||z
  }t        | ||«      \  }}t        t        |«      «      |dz   k(  r
|dz  }|dz  }|||fS )a¡  Round a rational number to a given number of significant figures.

    Rounds the rational number n/d to the given number of significant figures
    using the round-ties-to-even rule, and returns a triple
    (sign: bool, significand: int, exponent: int) representing the rounded
    value (-1)**sign * significand * 10**exponent.

    In the special case where n = 0, returns a significand of zero and
    an exponent of 1 - figures, for compatibility with formatting.
    Otherwise, the returned significand satisfies
    10**(figures - 1) <= significand < 10**figures.

    d must be positive, but n and d need not be relatively prime.
    figures must be positive.
    r   Fr   r   )Ústrr   Úlenr"   )	r   r   ÚfiguresÚstr_nÚstr_dÚmr   r!   Úsignificands	            r   Ú_round_to_figuresr,   g   s¤   € ð" 	ˆA‚vØ�a˜˜W™Ð$Ð$ô ”s˜1“v“;¤ A£ˆ5€EÜˆE‹
”S˜“ZÑ 5¨E¡>Ñ2€Að �7‰{€HÜ*¨1¨a°Ó:Ñ€Dˆ+ô Œ3ˆ{ÓÓ ¨!¡Ò+Ø˜ÑˆØ�A‰ˆà�˜hÐ&Ð&r#   a›  
    (?:
        (?P<fill>.)?
        (?P<align>[<>=^])
    )?
    (?P<sign>[-+ ]?)
    (?P<no_neg_zero>z)?
    (?P<alt>\#)?
    # A '0' that's *not* followed by another digit is parsed as a minimum width
    # rather than a zeropad flag.
    (?P<zeropad>0(?=[0-9]))?
    (?P<minimumwidth>0|[1-9][0-9]*)?
    (?P<thousands_sep>[,_])?
    (?:\.(?P<precision>0|[1-9][0-9]*))?
    (?P<presentation_type>[eEfFgG%])
c                   óŠ  ‡ — e Zd ZdZdZd,ˆ fd„	Zed„ «       Zed„ «       Zeˆ fd„«       Z	d„ Z
d„ Zd-d	„Zed
„ «       Zed„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Z eeej,                  «      \  ZZd„ Z eeej4                  «      \  ZZd„ Z eeej<                  «      \  ZZ d„ Z! ee!ejD                  «      \  Z#Z$d„ Z% ee%ejL                  «      \  Z'Z(d„ Z) ee)e*«      \  Z+Z,d„ Z- ee-ej\                  «      \  Z/Z0d„ Z1d„ Z2d„ Z3d„ Z4d„ Z5ejl                  fd„Z7d„ Z8d„ Z9d„ Z:d.d „Z;d!„ Z<d"„ Z=d#„ Z>d$„ Z?d%„ Z@d&„ ZAd'„ ZBd(„ ZCd)„ ZDd*„ ZEd+„ ZFˆ xZGS )/r   a]  This class implements rational numbers.

    In the two-argument form of the constructor, Fraction(8, 6) will
    produce a rational number equivalent to 4/3. Both arguments must
    be Rational. The numerator defaults to 0 and the denominator
    defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.

    Fractions can also be constructed from:

      - numeric strings similar to those accepted by the
        float constructor (for example, '-2.3' or '1e10')

      - strings of the form '123/456'

      - float and Decimal instances

      - other Rational instances (including integers)

    ©Ú
_numeratorÚ_denominatorc                 óB  •— t         t        | �  | «      }|�€©t        |«      t        u r||_        d|_        |S t        |t        j                  «      r$|j                  |_        |j                  |_        |S t        |t        t        f«      r|j                  «       \  |_        |_        |S t        |t        «      rút         j#                  |«      }|€t%        d|z  «      ‚t	        |j'                  d«      xs d«      }|j'                  d«      }|rt	        |«      }n€d}|j'                  d«      }|r6|j)                  dd«      }d	t+        |«      z  }||z  t	        |«      z   }||z  }|j'                  d
«      }|r"t	        |«      }|dk\  r	|d	|z  z  }n	|d	| z  z  }|j'                  d«      dk(  r¤| }n t-        d«      ‚t        |«      t        cxu rt        |«      u rn nnrt        |t        j                  «      rMt        |t        j                  «      r3|j                  |j                  z  |j                  |j                  z  }}nt-        d«      ‚|dk(  rt/        d|z  «      ‚t1        j2                  ||«      }	|dk  r|	 }	||	z  }||	z  }||_        ||_        |S )a£  Constructs a Rational.

        Takes a string like '3/2' or '1.5', another Rational instance, a
        numerator/denominator pair, or a float.

        Examples
        --------

        >>> Fraction(10, -8)
        Fraction(-5, 4)
        >>> Fraction(Fraction(1, 7), 5)
        Fraction(1, 35)
        >>> Fraction(Fraction(1, 7), Fraction(2, 3))
        Fraction(3, 14)
        >>> Fraction('314')
        Fraction(314, 1)
        >>> Fraction('-35/4')
        Fraction(-35, 4)
        >>> Fraction('3.1415') # conversion from numeric string
        Fraction(6283, 2000)
        >>> Fraction('-47e-2') # string may include a decimal exponent
        Fraction(-47, 100)
        >>> Fraction(1.47)  # direct construction from float (exact conversion)
        Fraction(6620291452234629, 4503599627370496)
        >>> Fraction(2.25)
        Fraction(9, 4)
        >>> Fraction(Decimal('1.47'))
        Fraction(147, 100)

        r   z Invalid literal for Fraction: %rÚnumÚ0ÚdenomÚdecimalÚ_Ú r   Úexpr   r!   ú-z2argument should be a string or a Rational instancez+both arguments should be Rational instancesúFraction(%s, 0))Úsuperr   Ú__new__ÚtypeÚintr/   r0   Ú
isinstanceÚnumbersÚRationalr   r   Úfloatr   Úas_integer_ratior%   Ú_RATIONAL_FORMATÚmatchr   ÚgroupÚreplacer&   Ú	TypeErrorÚZeroDivisionErrorÚmathÚgcd)Úclsr   r   Úselfr*   r4   r5   Úscaler8   ÚgÚ	__class__s             €r   r<   zFraction.__new__º   s˜  ø€ ô> ”X˜sÑ+¨CÓ0ˆàÑÜ�I‹¤#Ñ%Ø"+�”Ø$%�Ô!Ø�ä˜I¤w×'7Ñ'7Ô8Ø"+×"5Ñ"5�”Ø$-×$9Ñ$9�Ô!Ø�ä˜I¬¬wÐ'7Ô8à5>×5OÑ5OÓ5QÑ2�” Ô!2Ø�ä˜I¤sÔ+ä$×*Ñ*¨9Ó5�Ø�9Ü$Ð%GØ%.ñ&/ó 0ð 0ä §¡¨£Ò 5°#Ó6�	ØŸ™ Ó(�ÙÜ"% e£*‘Kà"#�KØŸg™g iÓ0�GÙØ")§/¡/°#°rÓ":˜Ø "¤C¨£LÑ 0˜Ø$-°Ñ$5¼¸G»Ñ$D˜	Ø# uÑ,˜ØŸ'™' %›.�CÙÜ! #›h˜Ø !š8Ø%¨¨S©Ñ0™Ià'¨2°¨t©8Ñ3˜KØ—7‘7˜6“? cÒ)Ø!* 
‘Iô  ð !9ó :ð :ô �)‹_¤Ó8¤t¨KÓ'8Ô8Øä˜¤G×$4Ñ$4Ô5Ü�{¤G×$4Ñ$4Ô5à×#Ñ# k×&=Ñ&=Ñ=Ø×%Ñ%¨	×(=Ñ(=Ñ=ð #‰Iô
 ð 1ó 2ð 2ð ˜!ÒÜ#Ð$5¸	Ñ$AÓBÐBÜ�H‰H�Y Ó,ˆØ˜Š?Ø�ˆAØ�a‰ˆ	Ø˜ÑˆØ#ˆŒØ'ˆÔØˆr#   c           	      ó  — t        |t        j                  «      r | |«      S t        |t        «      s1t	        | j
                  ›d|›dt        |«      j
                  ›d�«      ‚ | j                  |j                  «       Ž S )z‚Converts a finite float to a rational number, exactly.

        Beware that Fraction.from_float(0.3) != Fraction(3, 10).

        z%.from_float() only takes floats, not ú (ú))	r?   r@   ÚIntegralrB   rH   Ú__name__r=   Ú_from_coprime_intsrC   )rL   Úfs     r   Ú
from_floatzFraction.from_float#  sm   € ô �aœ×)Ñ)Ô*Ù�q“6ˆMÜ˜AœuÔ%ÜØ Ÿ\›\ª1¬d°1«g×.>Ó.>ð@ó Að Aà%ˆs×%Ñ% q×'9Ñ'9Ó';Ð<Ð<r#   c           	      ó  — ddl m} t        |t        j                  «      r |t        |«      «      }n=t        ||«      s1t        | j                  ›d|›dt        |«      j                  ›d�«      ‚ | j                  |j                  «       Ž S )zAConverts a finite Decimal instance to a rational number, exactly.r   r   z).from_decimal() only takes Decimals, not rR   rS   )r5   r   r?   r@   rT   r>   rH   rU   r=   rV   rC   )rL   Údecr   s      r   Úfrom_decimalzFraction.from_decimal1  st   € õ 	$Ü�cœ7×+Ñ+Ô,Ùœ#˜c›(Ó#‰CÜ˜C Ô)Üà—“šs¤D¨£I×$6Ó$6ð8ó9ð 9ð &ˆs×%Ñ% s×';Ñ';Ó'=Ð>Ð>r#   c                óJ   •— t         t        | �  | «      }||_        ||_        |S )z°Convert a pair of ints to a rational number, for internal use.

        The ratio of integers should be in lowest terms and the denominator
        should be positive.
        )r;   r   r<   r/   r0   )rL   r   r   ÚobjrP   s       €r   rV   zFraction._from_coprime_ints=  s*   ø€ ô ”H˜cÑ*¨3Ó/ˆØ"ˆŒØ&ˆÔØˆ
r#   c                 ó    — | j                   dk(  S )z*Return True if the Fraction is an integer.r   ©r0   ©rM   s    r   Ú
is_integerzFraction.is_integerI  s   € à× Ñ  AÑ%Ð%r#   c                 ó2   — | j                   | j                  fS )z˜Return a pair of integers, whose ratio is equal to the original Fraction.

        The ratio is in lowest terms and has a positive denominator.
        r.   r`   s    r   rC   zFraction.as_integer_ratioM  s   € ð
 —‘ ×!2Ñ!2Ð3Ð3r#   c                 óª  — |dk  rt        d«      ‚| j                  |k  rt        | «      S d\  }}}}| j                  | j                  }}	 ||z  }|||z  z   }	|	|kD  rn|||||z  z   |	f\  }}}}||||z  z
  }}Œ/||z
  |z  }
d|z  ||
|z  z   z  | j                  k  rt        j	                  ||«      S t        j	                  ||
|z  z   ||
|z  z   «      S )aW  Closest Fraction to self with denominator at most max_denominator.

        >>> Fraction('3.141592653589793').limit_denominator(10)
        Fraction(22, 7)
        >>> Fraction('3.141592653589793').limit_denominator(100)
        Fraction(311, 99)
        >>> Fraction(4321, 8765).limit_denominator(10000)
        Fraction(4321, 8765)

        r   z$max_denominator should be at least 1)r   r   r   r   é   )r   r0   r   r/   rV   )rM   Úmax_denominatorÚp0Úq0Úp1Úq1r   r   ÚaÚq2Úks              r   Úlimit_denominatorzFraction.limit_denominatorT  s  € ð@ ˜QÒÜÐCÓDÐDØ×Ñ Ò/Ü˜D“>Ð!à#‰ˆˆB��BØ�‰ × 1Ñ 1ˆ1ˆØØ�1‘ˆAØ�A�b‘D‘ˆBØ�OÒ#ØØ  R¨¨"©¡W¨bÐ0‰NˆB��B˜Ø�a˜˜!™‘eˆqˆAð ð ˜RÑ "Ñ$ˆð ˆQ‰3��1�R‘4‘‰=˜D×-Ñ-Ò-Ü×.Ñ.¨r°2Ó6Ð6ä×.Ñ.¨r°!°B±$©w¸¸1¸R¹4¹Ó@Ð@r#   c                 ó   — | j                   S ©N)r/   ©rj   s    r   r   zFraction.numerator�  s   € à�|‰|Ðr#   c                 ó   — | j                   S ro   r_   rp   s    r   r   zFraction.denominator‘  s   € à�~‰~Ðr#   c                 óh   — | j                   j                  ›d| j                  ›d| j                  ›d�S )z
repr(self)ú(z, rS   )rP   rU   r/   r0   r`   s    r   Ú__repr__zFraction.__repr__•  s*   € à#Ÿ~™~×6Ó6Ø#Ÿ›°×0AÓ0AðCð 	Cr#   c                 ó€   — | j                   dk(  rt        | j                  «      S | j                  ›d| j                   ›�S )z	str(self)r   ú/)r0   r%   r/   r`   s    r   Ú__str__zFraction.__str__š  s4   € à×Ñ Ò!Ü�t—‘Ó'Ð'à"Ÿo›o¨t×/@Ò/@ÐAÐAr#   c          
      óÖ  ‡ ‡!— |st        | «      S t        |«      }|€$t        d|›dt        | «      j                  ›�«      ‚|d   �*|d   �%t        d|›dt        | «      j                  ›d�«      ‚|d   xs d}|d   xs d	}|d
   dk(  rdn|d
   }t        |d   «      }t        |d   «      }t        |d   «      }t        |d   xs d«      }	|d   Š!t        |d   xs d«      }
|d   }|dv xr | }| }|dv rdnd}|dv r7|
 }|dk(  r|dz  }t        | j                  | j                  ||«      \  }}d}|
}nY|dv rt        |
d«      n|
dz   }t        | j                  | j                  |«      \  }}}|dv xs |dkD  xs ||z   d k  }|r|dz
  n| }|dk(  rd}n|r|› ||z   d!›�}nd}|d|dz   › d"�›}|rdn|}|dt        |«      |z
   Š |t        |«      |z
  d }|r|j                  d«      }|r|sdnd#}||z   |z   }|r8|	t        |«      z
  t        |«      z
  }‰ j                  ‰!rd$|z  d%z  dz   n|«      Š ‰!rIdt        ‰ «      dz
  d$z  z   }‰ d| dj                  ˆ ˆ!fd&„t!        |t        ‰ «      d$«      D «       «      z   Š ‰ |z   }||	t        |«      z
  t        |«      z
  z  }|d	k(  r||z   |z   S |d'k(  r||z   |z   S |d(k(  rt        |«      dz  }|d| |z   |z   ||d z   S ||z   |z   S ))zAFormat this fraction according to the given format specification.NzInvalid format specifier z for object of type ÚalignÚzeropadz0; can't use explicit alignment when zero-paddingÚfillú ú>r!   r9   r7   r   ÚaltÚminimumwidthr3   Úthousands_sepÚ	precisionÚ6Úpresentation_typeÚgGÚEFGÚEÚezfF%ú%rd   Fr   ÚeEr   éüÿÿÿz+03dr   ú.é   é   c              3   ó4   •K  — | ]  }‰‰||d z    z   –— Œ y­w)rŒ   N© )Ú.0ÚposÚleadingr€   s     €€r   ú	<genexpr>z&Fraction.__format__.<locals>.<genexpr>  s)   øè ø€ ò 4àð  ¨¨c°A©gÐ 6Õ6ñ4ùs   ƒú<ú^)r%   Ú#_FLOAT_FORMAT_SPECIFICATION_MATCHERr   r=   rU   Úboolr>   r"   r/   r0   Úmaxr,   r&   ÚrstripÚzfillÚjoinÚrange)"rM   Úformat_specrE   r{   ry   Úpos_signr   Úalternate_formrz   r   r�   rƒ   Ú
trim_zerosÚ
trim_pointÚexponent_indicatorr   Únegativer+   Ú
scientificÚ	point_posr'   ÚsuffixÚdigitsr!   Ú	frac_partÚ	separatorÚtrailingÚmin_leadingÚ	first_posÚbodyÚpaddingÚhalfr’   r€   s"                                   @@r   Ú
__format__zFraction.__format__¡  s  ù€ ñ Ü�t“9Ðô 4°KÓ@ˆØˆ=ÜØ+¨K¨?ð ;&Ü&*¨4£j×&9Ñ&9Ð%<ð>óð ð �7‰^Ð'¨E°)Ñ,<Ð,HäØ+¨K¨?ð ;&Ü&*¨4£j×&9Ñ&9Ð%<ð =AðAóð ð
 �V‰}Ò# ˆØ�g‘Ò% #ˆØ˜v™¨#Ò-‘2°5¸±=ˆÜ˜5 Ñ/Ó0ˆÜ˜e E™lÓ+ˆÜ�u˜YÑ'Ó(ˆÜ˜5 Ñ0Ò7°CÓ8ˆØ˜oÑ.ˆÜ˜˜kÑ*Ò1¨cÓ2ˆ	Ø!Ð"5Ñ6ÐØ&¨$Ð.ÒE°~Ð3Eˆ
Ø'Ð'ˆ
Ø$5¸Ñ$>™SÀCÐð  Ñ%Ø!�zˆHØ  CÒ'Ø˜A‘�Ü$6Ø—‘ ×!2Ñ!2°H¸kó%KÑ!ˆH�kàˆJØ!‰Ið %¨Ñ,ô �I˜qÔ!à ‘]ð ô
 /@Ø—‘ ×!2Ñ!2°Gó/=Ñ+ˆH�k 8ð " TÐ)ò ,Ø˜a‘<ò,à˜gÑ%¨Ñ+ð ñ
 (2˜ !š¸°yˆIð  Ò#Ø‰FÙØ*Ð+¨H°yÑ,@ÀÐ+FÐG‰FàˆFð    )¨a¡- °Ð1Ð2ˆñ
 ‰s HˆØÐ2œ3˜v›;¨Ñ2Ð3ˆØœ3˜v›;¨Ñ2Ð4Ð5ˆ	ÙØ!×(Ñ(¨Ó-ˆIÙ$©Y‘B¸Cˆ	Ø˜yÑ(¨6Ñ1ˆñ Ø&¬¨T«Ñ2´S¸³]ÑBˆKð —m‘mÙ,9��K‘ 1Ñ$ qÒ(¸{óˆGñ
 ØœS ›\¨AÑ-°Ñ2Ñ2ˆIØ˜j˜yÐ)¨B¯G©Gô 4ä  ¬C°«L¸!Ó<ô4ó -ñ ˆGð ˜Ñ!ˆØ˜,¬¨T«Ñ2´S¸³YÑ>Ñ?ˆØ�CŠ<Ø˜T‘> DÑ(Ð(Ø�cŠ\Ø˜$‘; Ñ(Ð(Ø�cŠ\Ü�w“< 1Ñ$ˆDØ˜5˜D�> DÑ(¨4Ñ/°'¸$¸%°.Ñ@Ð@à˜'‘> DÑ(Ð(r#   c                 óÆ   ‡ ‡— ˆˆ fd„}d‰j                   z   dz   |_         ‰ j                  |_        ˆˆ fd„}d‰j                   z   dz   |_         ‰ j                  |_        ||fS )aÕ  Generates forward and reverse operators given a purely-rational
        operator and a function from the operator module.

        Use this like:
        __op__, __rop__ = _operator_fallbacks(just_rational_op, operator.op)

        In general, we want to implement the arithmetic operations so
        that mixed-mode operations either call an implementation whose
        author knew about the types of both arguments, or convert both
        to the nearest built in type and do the operation there. In
        Fraction, that means that we define __add__ and __radd__ as:

            def __add__(self, other):
                # Both types have numerators/denominator attributes,
                # so do the operation directly
                if isinstance(other, (int, Fraction)):
                    return Fraction(self.numerator * other.denominator +
                                    other.numerator * self.denominator,
                                    self.denominator * other.denominator)
                # float and complex don't have those operations, but we
                # know about those types, so special case them.
                elif isinstance(other, float):
                    return float(self) + other
                elif isinstance(other, complex):
                    return complex(self) + other
                # Let the other type take over.
                return NotImplemented

            def __radd__(self, other):
                # radd handles more types than add because there's
                # nothing left to fall back to.
                if isinstance(other, numbers.Rational):
                    return Fraction(self.numerator * other.denominator +
                                    other.numerator * self.denominator,
                                    self.denominator * other.denominator)
                elif isinstance(other, Real):
                    return float(other) + float(self)
                elif isinstance(other, Complex):
                    return complex(other) + complex(self)
                return NotImplemented


        There are 5 different cases for a mixed-type addition on
        Fraction. I'll refer to all of the above code that doesn't
        refer to Fraction, float, or complex as "boilerplate". 'r'
        will be an instance of Fraction, which is a subtype of
        Rational (r : Fraction <: Rational), and b : B <:
        Complex. The first three involve 'r + b':

            1. If B <: Fraction, int, float, or complex, we handle
               that specially, and all is well.
            2. If Fraction falls back to the boilerplate code, and it
               were to return a value from __add__, we'd miss the
               possibility that B defines a more intelligent __radd__,
               so the boilerplate should return NotImplemented from
               __add__. In particular, we don't handle Rational
               here, even though we could get an exact answer, in case
               the other type wants to do something special.
            3. If B <: Fraction, Python tries B.__radd__ before
               Fraction.__add__. This is ok, because it was
               implemented with knowledge of Fraction, so it can
               handle those instances before delegating to Real or
               Complex.

        The next two situations describe 'b + r'. We assume that b
        didn't know about Fraction in its implementation, and that it
        uses similar boilerplate code:

            4. If B <: Rational, then __radd_ converts both to the
               builtin rational type (hey look, that's us) and
               proceeds.
            5. Otherwise, __radd__ tries to find the nearest common
               base ABC, and fall back to its builtin type. Since this
               class doesn't subclass a concrete type, there's no
               implementation to fall back to, so we need to try as
               hard as possible to return an actual value, or the user
               will get a TypeError.

        c                 ó  •— t        |t        «      r	 ‰| |«      S t        |t        «      r ‰| t        |«      «      S t        |t        «      r ‰t        | «      |«      S t        |t        «      r ‰t	        | «      |«      S t
        S ro   )r?   r   r>   rB   ÚcomplexÚNotImplemented)rj   ÚbÚfallback_operatorÚmonomorphic_operators     €€r   Úforwardz-Fraction._operator_fallbacks.<locals>.forwarde  sq   ø€ Ü˜!œXÔ&Ù+¨A¨qÓ1Ð1Ü˜AœsÔ#Ù+¨A¬x¸«{Ó;Ð;Ü˜AœuÔ%Ù(¬¨q«°1Ó5Ð5Ü˜AœwÔ'Ù(¬°«°QÓ7Ð7ä%Ð%r#   Ú__c                 ó<  •— t        |t        j                  «      r ‰t        |«      | «      S t        |t        j                  «      r ‰t        |«      t        | «      «      S t        |t        j                  «      r ‰t        |«      t        | «      «      S t        S ro   )	r?   r@   rA   r   ÚRealrB   ÚComplexr³   r´   )rµ   rj   r¶   r·   s     €€r   Úreversez-Fraction._operator_fallbacks.<locals>.reverses  sp   ø€ Ü˜!œW×-Ñ-Ô.á+¬H°Q«K¸Ó;Ð;Ü˜AœwŸ|™|Ô,Ù(¬¨q«´5¸³8Ó<Ð<Ü˜AœwŸ™Ô/Ù(¬°«´W¸Q³ZÓ@Ð@ä%Ð%r#   Ú__r)rU   Ú__doc__)r·   r¶   r¸   r½   s   ``  r   Ú_operator_fallbackszFraction._operator_fallbacks  si   ù€ õ`
	&ð  Ð"3×"<Ñ"<Ñ<¸tÑCˆÔØ.×6Ñ6ˆŒõ		&ð !Ð#4×#=Ñ#=Ñ=ÀÑDˆÔØ.×6Ñ6ˆŒà˜ÐÐr#   c                 ó¨  — | j                   | j                  }}|j                   |j                  }}t        j                  ||«      }|dk(  r"t        j                  ||z  ||z  z   ||z  «      S ||z  }|||z  z  ||z  z   }t        j                  ||«      }	|	dk(  rt        j                  |||z  «      S t        j                  ||	z  |||	z  z  «      S )za + br   ©r/   r0   rJ   rK   r   rV   ©
rj   rµ   ÚnaÚdaÚnbÚdbrO   ÚsÚtÚg2s
             r   Ú_addzFraction._addÆ  óÊ   € à—‘˜qŸ~™~ˆBˆØ—‘˜qŸ~™~ˆBˆÜ�H‰H�R˜ÓˆØ�Š6Ü×.Ñ.¨r°B©w¸¸b¹Ñ/@À"ÀrÁ'ÓJÐJØ�!‰GˆØ�"˜‘'‰N˜R !™VÑ#ˆÜ�X‰X�a˜‹^ˆØ�Š7Ü×.Ñ.¨q°!°b±&Ó9Ð9Ü×*Ñ*¨1°©7°A¸¸r¹±NÓCÐCr#   c                 ó¨  — | j                   | j                  }}|j                   |j                  }}t        j                  ||«      }|dk(  r"t        j                  ||z  ||z  z
  ||z  «      S ||z  }|||z  z  ||z  z
  }t        j                  ||«      }	|	dk(  rt        j                  |||z  «      S t        j                  ||	z  |||	z  z  «      S )za - br   rÂ   rÃ   s
             r   Ú_subzFraction._subÖ  rÌ   r#   c                 ó.  — | j                   | j                  }}|j                   |j                  }}t        j                  ||«      }|dkD  r
||z  }||z  }t        j                  ||«      }|dkD  r
||z  }||z  }t        j                  ||z  ||z  «      S )za * br   rÂ   )rj   rµ   rÄ   rÅ   rÆ   rÇ   Úg1rÊ   s           r   Ú_mulzFraction._mulæ  s‘   € à—‘˜qŸ~™~ˆBˆØ—‘˜qŸ~™~ˆBˆÜ�X‰X�b˜"ÓˆØ�Š6Ø�2‰IˆBØ�2‰IˆBÜ�X‰X�b˜"ÓˆØ�Š6Ø�2‰IˆBØ�2‰IˆBÜ×*Ñ*¨2°©7°B¸±GÓ<Ð<r#   c                 ór  — |j                   |j                  }}|dk(  rt        d|z  «      ‚| j                   | j                  }}t        j                  ||«      }|dkD  r
||z  }||z  }t        j                  ||«      }|dkD  r
||z  }||z  }||z  ||z  }	}|	dk  r| |	 }	}t
        j                  ||	«      S )za / br   r:   r   )r/   r0   rI   rJ   rK   r   rV   )
rj   rµ   rÆ   rÇ   rÄ   rÅ   rÐ   rÊ   r   r   s
             r   Ú_divzFraction._divö  sÈ   € ð —‘˜qŸ~™~ˆBˆØ�Š7Ü#Ð$5¸Ñ$:Ó;Ð;Ø—‘˜qŸ~™~ˆBˆÜ�X‰X�b˜"ÓˆØ�Š6Ø�2‰IˆBØ�2‰IˆBÜ�X‰X�b˜"ÓˆØ�Š6Ø�2‰IˆBØ�2‰IˆBØ�B‰w˜˜R™ˆ1ˆØˆqŠ5Ø�2˜�rˆqˆAÜ×*Ñ*¨1¨aÓ0Ð0r#   c                 óh   — | j                   |j                  z  | j                  |j                   z  z  S )za // b)r   r   ©rj   rµ   s     r   Ú	_floordivzFraction._floordiv  s'   € à—‘˜aŸm™mÑ+°·±ÀÇÁÑ1LÑMÐMr#   c                 ó¦   — | j                   |j                   }}t        | j                  |z  ||j                  z  «      \  }}|t        |||z  «      fS )z(a // b, a % b))r   r   r   r   )rj   rµ   rÅ   rÇ   ÚdivÚn_mods         r   Ú_divmodzFraction._divmod  sK   € à—‘ §¡ˆBˆÜ˜AŸK™K¨"Ñ,¨b°1·;±;Ñ.>Ó?‰
ˆˆUØ”H˜U B¨¡GÓ,Ð,Ð,r#   c                 óŠ   — | j                   |j                   }}t        | j                  |z  |j                  |z  z  ||z  «      S )za % b)r   r   r   )rj   rµ   rÅ   rÇ   s       r   Ú_modzFraction._mod  s;   € à—‘ §¡ˆBˆÜ˜Ÿ™ rÑ)¨a¯k©k¸BÑ.>Ñ?ÀÀbÁÓIÐIr#   c                 ób  — t        |t        j                  «      �r|j                  dk(  rá|j                  }|dk\  r0t
        j                  | j                  |z  | j                  |z  «      S | j                  dkD  r2t
        j                  | j                  | z  | j                  | z  «      S | j                  dk(  rt        d| j                  | z  z  «      ‚t
        j                  | j                   | z  | j                   | z  «      S t        | «      t        |«      z  S t        | «      |z  S )z¾a ** b

        If b is not an integer, the result will be a float or complex
        since roots are generally irrational. If b is an integer, the
        result will be rational.

        r   r   r:   )r?   r@   rA   r   r   r   rV   r/   r0   rI   rB   )rj   rµ   Úpowers      r   Ú__pow__zFraction.__pow__!  s#  € ô �aœ×)Ñ)Õ*Ø�}‰} Ò!ØŸ™�Ø˜A’:Ü#×6Ñ6°q·|±|ÀuÑ7LØ78·~±~ÈÑ7NóPð Pà—\‘\ AÒ%Ü#×6Ñ6°q·~±~È%ÈÑ7OØ78·|±|ÈÀvÑ7MóOð Oà—\‘\ QÒ&Ü+Ð,=Ø,-¯N©N¸u¸fÑ,Dñ-Eó Fð Fô $×6Ñ6¸¿¹¸ÈUÈFÑ7RØ9:¿¹¸È5È&Ñ7PóRð Rô
 ˜Q“x¤5¨£8Ñ+Ð+ä˜“8˜q‘=Ð r#   c                 ó.  — | j                   dk(  r| j                  dk\  r|| j                  z  S t        |t        j                  «      r#t        |j                  |j                  «      | z  S | j                   dk(  r|| j                  z  S |t        | «      z  S )za ** br   r   )	r0   r/   r?   r@   rA   r   r   r   rB   )rµ   rj   s     r   Ú__rpow__zFraction.__rpow__?  s{   € à�>‰>˜QÒ 1§<¡<°1Ò#4à˜Ÿ™Ñ$Ð$ä�aœ×)Ñ)Ô*Ü˜AŸK™K¨¯©Ó7¸1Ñ<Ð<à�>‰>˜QÒØ˜Ÿ™Ñ$Ð$à”E˜!“H‰}Ðr#   c                 óV   — t         j                  | j                  | j                  «      S )z++a: Coerces a subclass instance to Fraction©r   rV   r/   r0   rp   s    r   Ú__pos__zFraction.__pos__M  s   € ä×*Ñ*¨1¯<©<¸¿¹ÓHÐHr#   c                 óX   — t         j                  | j                   | j                  «      S )z-arã   rp   s    r   Ú__neg__zFraction.__neg__Q  s   € ä×*Ñ*¨A¯L©L¨=¸!¿.¹.ÓIÐIr#   c                 óh   — t         j                  t        | j                  «      | j                  «      S )zabs(a))r   rV   r   r/   r0   rp   s    r   Ú__abs__zFraction.__abs__U  s"   € ä×*Ñ*¬3¨q¯|©|Ó+<¸a¿n¹nÓMÐMr#   c                 ó    — | j                   dk  r! || j                    | j                  z   «      S  || j                   | j                  z  «      S )zint(a)r   r.   )rj   Ú_indexs     r   Ú__int__zFraction.__int__Y  sC   € à�<‰<˜!ÒÙ˜QŸ\™\˜M¨Q¯^©^Ñ;Ð<Ó=Ð=á˜!Ÿ,™,¨!¯.©.Ñ8Ó9Ð9r#   c                 óˆ   — | j                   dk  r| j                    | j                  z   S | j                   | j                  z  S )zmath.trunc(a)r   r.   rp   s    r   Ú	__trunc__zFraction.__trunc__`  s9   € à�<‰<˜!ÒØ—l‘l�] a§n¡nÑ4Ð5Ð5à—<‘< 1§>¡>Ñ1Ð1r#   c                 ó4   — | j                   | j                  z  S )zmath.floor(a)r.   rp   s    r   Ú	__floor__zFraction.__floor__g  s   € à�|‰|˜qŸ~™~Ñ-Ð-r#   c                 ó8   — | j                    | j                  z   S )zmath.ceil(a)r.   rp   s    r   Ú__ceil__zFraction.__ceil__k  s   € ð —,‘,� !§.¡.Ñ0Ð1Ð1r#   c                 ó&  — |€K| j                   }t        | j                  |«      \  }}|dz  |k  r|S |dz  |kD  r|dz   S |dz  dk(  r|S |dz   S dt        |«      z  }|dkD  rt	        t        | |z  «      |«      S t	        t        | |z  «      |z  «      S )z?round(self, ndigits)

        Rounds half toward even.
        rd   r   r   r   )r0   r   r/   r   r   Úround)rM   Úndigitsr   ÚfloorÚ	remainderÚshifts         r   Ú	__round__zFraction.__round__p  s°   € ð
 ˆ?Ø×!Ñ!ˆAÜ% d§o¡o°qÓ9ÑˆE�9Ø˜1‰}˜qÒ Ø�Ø˜Q‘ Ò"Ø˜q‘yÐ à˜‘˜a’Ø�à˜q‘yÐ Ø”C˜“LÑ ˆð �QŠ;ÜœE $¨¡,Ó/°Ó7Ð7äœE $¨¡,Ó/°%Ñ7Ó8Ð8r#   c                 óB   — t        | j                  | j                  «      S )z
hash(self))r   r/   r0   r`   s    r   Ú__hash__zFraction.__hash__Š  s   € ä˜tŸ™°×0AÑ0AÓBÐBr#   c                 ó  — t        |«      t        u r | j                  |k(  xr | j                  dk(  S t	        |t
        j                  «      r4| j                  |j                  k(  xr | j                  |j                  k(  S t	        |t
        j                  «      r|j                  dk(  r|j                  }t	        |t        «      rCt        j                  |«      st        j                  |«      rd|k(  S | | j!                  |«      k(  S t"        S )za == br   r   ç        )r=   r>   r/   r0   r?   r@   rA   r   r   r¼   ÚimagÚrealrB   rJ   ÚisnanÚisinfrX   r´   rÕ   s     r   Ú__eq__zFraction.__eq__Ž  sÊ   € ä�‹7”c‰>Ø—<‘< 1Ñ$Ò<¨¯©¸1Ñ)<Ð<Ü�aœ×)Ñ)Ô*Ø—L‘L A§K¡KÑ/ò 4Ø—N‘N a§m¡mÑ3ð5ä�aœŸ™Ô)¨a¯f©f¸ªkØ—‘ˆAÜ�aœÔÜ�z‰z˜!Œ}¤§
¡
¨1¤ð ˜a‘x�à˜AŸL™L¨›OÑ+Ð+ô "Ð!r#   c                 óf  — t        |t        j                  «      r7 || j                  |j                  z  | j
                  |j                  z  «      S t        |t        «      rKt        j                  |«      st        j                  |«      r	 |d|«      S  || | j                  |«      «      S t        S )ac  Helper for comparison operators, for internal use only.

        Implement comparison between a Rational instance `self`, and
        either another Rational instance or a float `other`.  If
        `other` is not a Rational instance or a float, return
        NotImplemented. `op` should be one of the six standard
        comparison operators.

        rü   )r?   r@   rA   r/   r   r0   r   rB   rJ   rÿ   r   rX   r´   )rM   ÚotherÚops      r   Ú_richcmpzFraction._richcmp£  s�   € ô �eœW×-Ñ-Ô.Ù�d—o‘o¨×(9Ñ(9Ñ9Ø×'Ñ'¨%¯/©/Ñ9ó;ð ;ä�eœUÔ#Ü�z‰z˜%Ô ¤D§J¡J¨uÔ$5Ù˜#˜u“~Ð%á˜$ §¡°Ó 6Ó7Ð7ä!Ð!r#   c                 óB   — | j                  |t        j                  «      S )za < b)r  ÚoperatorÚltrÕ   s     r   Ú__lt__zFraction.__lt__¹  ó   € à�z‰z˜!œXŸ[™[Ó)Ð)r#   c                 óB   — | j                  |t        j                  «      S )za > b)r  r  ÚgtrÕ   s     r   Ú__gt__zFraction.__gt__½  r
  r#   c                 óB   — | j                  |t        j                  «      S )za <= b)r  r  ÚlerÕ   s     r   Ú__le__zFraction.__le__Á  r
  r#   c                 óB   — | j                  |t        j                  «      S )za >= b)r  r  ÚgerÕ   s     r   Ú__ge__zFraction.__ge__Å  r
  r#   c                 ó,   — t        | j                  «      S )za != 0)r—   r/   rp   s    r   Ú__bool__zFraction.__bool__É  s   € ô �A—L‘LÓ!Ð!r#   c                 óJ   — | j                   | j                  | j                  ffS ro   )rP   r/   r0   r`   s    r   Ú
__reduce__zFraction.__reduce__Ñ  s    € Ø—‘ §¡°$×2CÑ2CÐ DÐEÐEr#   c                 óv   — t        | «      t        k(  r| S | j                  | j                  | j                  «      S ro   ©r=   r   rP   r/   r0   r`   s    r   Ú__copy__zFraction.__copy__Ô  ó.   € Ü�‹:œÒ!ØˆKØ�~‰~˜dŸo™o¨t×/@Ñ/@ÓAÐAr#   c                 óv   — t        | «      t        k(  r| S | j                  | j                  | j                  «      S ro   r  )rM   Úmemos     r   Ú__deepcopy__zFraction.__deepcopy__Ù  r  r#   )r   N)i@B ro   )HrU   Ú
__module__Ú__qualname__r¿   Ú	__slots__r<   ÚclassmethodrX   r[   rV   ra   rC   rm   Úpropertyr   r   rt   rw   r°   rÀ   rË   r  ÚaddÚ__add__Ú__radd__rÎ   ÚsubÚ__sub__Ú__rsub__rÑ   ÚmulÚ__mul__Ú__rmul__rÓ   ÚtruedivÚ__truediv__Ú__rtruediv__rÖ   ÚfloordivÚ__floordiv__Ú__rfloordiv__rÚ   r   Ú
__divmod__Ú__rdivmod__rÜ   ÚmodÚ__mod__Ú__rmod__rß   rá   rä   ræ   rè   Úindexrë   rí   rï   rñ   rø   rú   r  r  r	  r  r  r  r  r  r  r  Ú__classcell__)rP   s   @r   r   r   ¢   sæ  ø„ ñð( /€IõgðR ñ=ó ð=ð ñ	?ó ð	?ð ó	ó ð	ò&ò4ó7Aðr ñó ðð ñó ðòCò
Bòr)òhk òbDñ ,¨D°(·,±,Ó?Ñ€GˆXòDñ ,¨D°(·,±,Ó?Ñ€GˆXò=ñ ,¨D°(·,±,Ó?Ñ€GˆXò1ñ( !4°D¸(×:JÑ:JÓ KÑ€K�òNñ #6°iÀ×ARÑARÓ"SÑ€L�-ò-ñ 2°'¸6ÓBÑ€J�òJñ
 ,¨D°(·,±,Ó?Ñ€GˆXò!ò<òIòJòNð #Ÿ.™.ó :ò2ò.ò2ó
9ò4Cò"ò*"ò,*ò*ò*ò*ò"òFòBö
Br#   )F)r¿   r5   r   Ú	functoolsrJ   r@   r  ÚreÚsysÚ__all__Ú	hash_infoÚmodulusr   Úinfr   Ú	lru_cacher   ÚcompileÚVERBOSEÚ
IGNORECASErD   r"   r,   ÚDOTALLÚ	fullmatchr–   rA   r   r�   r#   r   ú<module>rG     sæ   ðñ 6å Û Û Û Û Û 	Û 
àˆ,€ð
 —-‘-×'Ñ'€ð �m‰m×Ñ€à€×Ñ˜wÔ'ñ*ó (ð*ð@ �2—:‘:ð ð ‡Z�Z�"—-‘-Ñó!Ð ó"ò:$'ðR '1 b§j¡jð 2ð ‡Y�Y�—‘Ñó'÷ '™Yð $ô$zBˆw×Ñõ zBr#   