+
    Bi9                     6   ^ RI Ht ^ RIt^ RIt^ RIHt ]P                  t^ sRR lt ! R R]P                  4      t
 ! R R]P                  4      t ! R	 R
]P                  4      tR t ! R R]P                  4      t]R8X  d   ]P                   ! 4        R# R# )    )supportN)
cmp_to_keyc                 n   \         '       d   \        R V 4       VR,          pV'       d   VP                  \        V4      R7       MVP                  4        \	        V4      \	        V4      8w  d\   \        RV 4       \        R\	        V4      \	        V4      4       \        V4       \        V4       \        V4       \
        ^,          sR# \        V4       F\  w  rVW%,          pWgJg   K  \        RV 4       \        RWVV4       \        V4       \        V4       \        V4       \
        ^,          s R# 	  R# )z    checkingNNNkeyzerror inzlength mismatch;Nzout of order at index)verboseprintsortr   lennerrors	enumerate)tagexpectedrawcompareorigigoodmaybes   &&&&    %/usr/lib/python3.14/test/test_sort.pycheckr   
   s     wnc"q6DZ()

8}C j# #h-S:hdc
1X&*c")1E:(O$K#JqLG '    c                   ,   a  ] tR t^*t o R tR tRtV tR# )TestBasec           	       a ^ .p\        ^^
4       F5  p^V,          pVP                  \        V^,
          V^,           4      4       K7  	  VP                  . RO4        ! V3R lR\        4      o ! R R\        4      pV EFB  p\        \        V4      4      p\        '       d   \        RV4       VR,          p\        RWV4       VR,          pVP                  4        \        RWV4       VR,          p\        P                  ! V4       \        R	WV4       VR,          pVP                  4        VR,          p\        R
WvR 4       \        '       d   \        R4       \        R4       VR,          pVP                  \        R 4      R7       \        RWV4       \        V4      ^8  d/   R pVR,          pV P                  \        VP                  VR7       V U	u. uF  p	S! V	4      NK  	  pp	VR,          p\        P                  ! V4       RSn        Rp
 VP                  4        V
'       d   RSn        \        RWV4       \        V4       U	u. uF  q! \        P                   ! ^
4      V	4      NK!  	  pp	V Uu. uF  qVP"                  3NK  	  ppVP                  4        V UU	u. uF  w  rVNK	  	  ppp	\        RWV4       EKE  	  R# u up	i   \         d    Rp
 Li ; iu up	i u upi u up	pi )r   c                   >   <a  ] tR t^3t o RtR tV3R ltR tRtV t	R# )+TestBase.testStressfully.<locals>.ComplainsTc                    Wn         R # Nr   )selfr   s   &&r   __init__4TestBase.testStressfully.<locals>.Complains.__init__6   s    r   c                   < SP                   '       d9   \        P                  ! 4       R 8  d   \        '       d   \        RW4       \        hV P
                  VP
                  8  # )gMbP?z        complaining at)maybe_complainrandomr	   r
   RuntimeErrorr   )r"   other	Complainss   &&r   __lt__2TestBase.testStressfully.<locals>.Complains.__lt__9   sE    +++%0Gw6D&&vv''r   c                (    R V P                   ,          # )zComplains(%d)r!   r"   s   &r   __repr__4TestBase.testStressfully.<locals>.Complains.__repr__@   s    &//r   r!   N)
__name__
__module____qualname____firstlineno__r&   r#   r+   r/   __static_attributes____classdictcell__)__classdict__r*   s   @r   r*   r   3   s     !N(0 0r   r*   c                   2   a  ] tR t^Ct o R tR tR tRtV tR# )(TestBase.testStressfully.<locals>.Stablec                    Wn         W n        R # r    r   index)r"   r   r   s   &&&r   r#   1TestBase.testStressfully.<locals>.Stable.__init__D   s    
r   c                4    V P                   VP                   8  # r    r   r"   r)   s   &&r   r+   /TestBase.testStressfully.<locals>.Stable.__lt__H   s    xx%))++r   c                @    R V P                   V P                  3,          # )zStable(%d, %d)r;   r.   s   &r   r/   1TestBase.testStressfully.<locals>.Stable.__repr__K   s    '488TZZ*@@@r   )r<   r   N)	r1   r2   r3   r4   r#   r+   r/   r5   r6   r7   s   @r   Stabler9   C   s     ,A Ar   rD   zTesting sizer   identityreversedzrandom permutationzreversed via functionc                     W8  W8  ,
          # r     abs   &&r   <lambda>*TestBase.testStressfully.<locals>.<lambda>a   s    qsQSkr   z3    Checking against an insane comparison function.z?        If the implementation isn't careful, this may segfault.c                 Z    \        \        P                  ! 4       ^,          4      ^,
          #    )intr'   rI   s   &&r   rL   rM   g   s    FMMOa4G0H10Lr   r   z(an insane function left some permutationc                     \         hr    r(   xs   &r   bad_key)TestBase.testStressfully.<locals>.bad_keyk   s    &&r   TFz+exception during sort left some permutation	stabilityN)
   d   i  )rangeextendobjectlistr	   r
   r   reverser'   shuffler   r   r   assertRaisesr(   r&   	randranger<   )r"   sizespowernrD   rU   syrV   r   it_complainede	augmentedr*   s   &            @r   testStressfullyTestBase.testStressfully+   sl   1b\EU
ALLqsAaC) " 	_%	0 	0 		AV 		A AU1XAwna(!A*a#!AIIK*a#!ANN1&-!AIIK!A)11IJwKLWX!AFFz"LMFN<aC1v{'aD!!,G!D'()q!1qA)!ANN1'+I$!M% +0	(CQJ:?(C(Q((,a0(AC/01q!QWWqI1NN()ytqyA)+q$g D *   % $% D1)s*   K	K%K!9K&&K+KKc           
     (   ^ RI Hp ^ RIHp ^p^	pV! ^ 4      p\	        V^,           4       Fc  pV! \	        V4      VR7       FI  p\        \        V\	        V4      4      4      p\        V4      p	\        WR7      p
V P                  W4       KK  	  Ke  	  R# )r   )product)
itemgetter)repeatr   N)		itertoolsrn   operatorro   r[   r^   zipsortedassertEqual)r"   rn   ro   NELTSMAXSIZEpick0lengthtxsforcednatives   &          r   test_small_stabilityTestBase.test_small_stability   s{    %' 1GaK(FU5\&9#av/0.  0 : )r   rH   N)r1   r2   r3   r4   rk   r~   r5   r6   rC   s   @r   r   r   *   s     V%p1 1r   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )TestBugsc                   a  ! V3R  lR4      p\        ^24       Uu. uF	  q!! 4       NK  	  upoV P                  \        SP                  4       R# u upi )c                   .   <a  ] tR t^t o V3R ltRtV tR# )"TestBugs.test_bug453523.<locals>.Cc                   < S'       d,   \         P                   ! 4       R 8  d   SP                  4        MSP                  ^4       \         P                   ! 4       R8  # )g      ?g      ?)r'   popappend)r"   r)   Ls   &&r   r+   )TestBugs.test_bug453523.<locals>.C.__lt__   s8    4/EEGHHQK}},,r   rH   Nr1   r2   r3   r4   r+   r5   r6   )r7   r   s   @r   Cr      s     - -r   r   N)r[   ra   
ValueErrorr   )r"   r   r   r   s   &  @r   test_bug453523TestBugs.test_bug453523   sB    
	- 	-  )$)QQS)$*aff- %s   Ac                  a . p\        ^4       Fl  pV3R lp^^.oV P                  \        SP                  \	        V4      R7       V3R lpV P                  \        SP                  \	        V4      R7       V.pKn  	  R# )   c                 `   < SP                  ^4       SP                  4        W8  W8  ,
          # rO   )r   r   rU   rg   r   s   &&r   mutating_cmp7TestBugs.test_undetected_mutation.<locals>.mutating_cmp   s&    !%((r   r   c                 F   < SP                  ^4       SR W8  W8  ,
          # )rP   r   )r   r   s   &&r   r   r      s$    aD!%((r   N)r[   ra   r   r   r   )r"   memorywasterr   r   r   s   &   @r   test_undetected_mutation!TestBugs.test_undetected_mutation   sp    rA) 1Aj!&&j6NO) j!&&j6NO(>L r   rH   N)r1   r2   r3   r4   r   r   r5   r6   rC   s   @r   r   r      s     . * *r   r   c                   V   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
tV tR# )TestDecorateSortUndecoratec                    R P                  4       pVR,          p\        P                  ! V4       VP                  \        P
                  R7       R pVP                  \        V4      R7       R# ),The quick Brown fox Jumped over The lazy Dogr   r   c                 Z    V P                  4       VP                  4       r2W#8  W#8  ,
          # r    )lower)rU   rg   xlowerylowers   &&  r   my_cmp9TestDecorateSortUndecorate.test_decorated.<locals>.my_cmp   s$    WWY	FO88r   N)splitr'   r`   r   strr   r   )r"   datacopyr   s   &   r   test_decorated)TestDecorateSortUndecorate.test_decorated   sQ    =CCEAwt		cii	 	9 			j(	)r   c                l    R P                  4       pV P                  \        VP                  R R7       R# )r   c                     ^ # r   rH   rU   rg   s   &&r   rL   >TestDecorateSortUndecorate.test_baddecorator.<locals>.<lambda>   s    r   r   N)r   ra   	TypeErrorr   r"   r   s   & r   test_baddecorator,TestDecorateSortUndecorate.test_baddecorator   s)    =CCE)TYYMBr   c                    \        ^4       Uu. uF  p\        P                  ! ^d4      V3NK  	  ppVR,          pVP                  R R7       VP                  4        V P	                  W#4       R# u upi )   r   c                     V ^ ,          # r   rH   )rz   s   &r   rL   ;TestDecorateSortUndecorate.test_stability.<locals>.<lambda>   s    !r   r   N)r[   r'   rb   r   ru   )r"   r   r   r   s   &   r   test_stability)TestDecorateSortUndecorate.test_stability   s^    49#J?Jq!!#&*J?Aw		n	%		$	 @s   !A0c                    \        \        R^4      4      pVR,          pV P                  \        VP                  R R7       V P                  W4       R# )   r   c                     ^V ,          # )   rH   rT   s   &r   rL   DTestDecorateSortUndecorate.test_key_with_exception.<locals>.<lambda>   s    acr   r   N)r^   r[   ra   ZeroDivisionErrorr   ru   )r"   r   dups   &  r   test_key_with_exception2TestDecorateSortUndecorate.test_key_with_exception   sC    E"aL!1g+TYYMJ#r   c                   a \        \        ^
4      4      oV3R lpV P                  \        SP                  VR7       R# )rY   c                 *   < SR  \        ^4      SR &   V # )r   r[   )rU   r   s   &r   k<TestDecorateSortUndecorate.test_key_with_mutation.<locals>.k   s    QBiDGHr   r   N)r^   r[   ra   r   r   )r"   r   r   s   & @r   test_key_with_mutation1TestDecorateSortUndecorate.test_key_with_mutation   s0    E"I	 	*diiQ7r   c                   a \        \        ^
4      4      o ! V3R lR\        4      pV P                  \        SP
                  VR7       R# )rY   c                   :   <a  ] tR t^t o R tV3R ltR tRtV tR# )ITestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKillerc                    R # r    rH   r"   rU   s   &&r   r#   RTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__init__   s    r   c                *   < SR  \        ^4      SR &   R# r   Nr   r   s   &r   __del__QTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__del__   s    G)Qr   c                0    \        V 4      \        V4      8  # r    )idr?   s   &&r   r+   PTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__lt__   s    $x"U)++r   rH   N)	r1   r2   r3   r4   r#   r   r+   r5   r6   r7   r   s   @r   
SortKillerr      s     $, ,r   r   r   N)r^   r[   r]   ra   r   r   r"   r   r   s   & @r   test_key_with_mutating_del5TestDecorateSortUndecorate.test_key_with_mutating_del   s7    E"I	, 	, 	*diiZ@r   c                   a \        \        ^
4      4      o ! V3R lR\        4      pV P                  \        SP
                  VR7       R# )rY   c                   4   <a  ] tR t^t o R tV3R ltRtV tR# )WTestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKillerc                     V^8  d   \         hR# )r   NrS   r   s   &&r   r#   `TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__init__   s    q5&& r   c                <   < SR  \        \        ^4      4      SR &   R# r   )r^   r[   r   s   &r   r   _TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__del__   s    GuRy/Qr   rH   N)r1   r2   r3   r4   r#   r   r5   r6   r   s   @r   r   r      s     '* *r   r   r   N)r^   r[   r]   ra   r(   r   r   s   & @r   (test_key_with_mutating_del_and_exceptionCTestDecorateSortUndecorate.test_key_with_mutating_del_and_exception   s7    E"I	* 	* 	,		zBr   c           
         \        \        ^d4      4      p\        P                  ! V4       VP	                  RR7       V P                  V\        \        ^cRR4      4      4       R# )rZ   T)r_   N)r^   r[   r'   r`   r   ru   r   s   & r   test_reverse'TestDecorateSortUndecorate.test_reverse  sG    E#Jt		$	tE"RO45r   c                z   \        ^4       Uu. uF  p\        P                  ! ^d4      V3NK  	  ppVR,          pVR,          pR pR pVP                  \	        V4      RR7       VP                  \	        V4      R7       V P                  W#4       VP                  R RR7       V P                  W$4       R# u upi )	r   r   c                 >    V ^ ,          V^ ,          r2W#8  W#8  ,
          # r   rH   rU   rg   x0y0s   &&  r   r   ATestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmp       qT1Q4G((r   c                 >    V ^ ,          V^ ,          r2W28  W28  ,
          # r   rH   r   s   &&  r   my_cmp_reversedJTestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmp_reversed  r   r   T)r   r_   r   c                     V ^ ,          # r   rH   rT   s   &r   rL   CTestDecorateSortUndecorate.test_reverse_stability.<locals>.<lambda>  s    1r   N)r[   r'   rb   r   r   ru   )r"   r   r   copy1copy2r   r   s   &      r   test_reverse_stability1TestDecorateSortUndecorate.test_reverse_stability  s    49#J?Jq!!#&*J?QQ	)	) 			j($	7

z/2
3%

~t
4% @s   !B8rH   N)r1   r2   r3   r4   r   r   r   r   r   r   r   r   r   r5   r6   rC   s   @r   r   r      s:     *C%$8
A
C(6& &r   r   c                    \         P                  ! ^ 4       \         P                  ! V4       VR,          pV Uu. uF  q33NK  	  ppV Uu. uF  q333NK  	  ppW$V3 Fe  p\        V4      p\        V Uu. uF  p^ V3NK	  	  up4       Uu. uF  qw^,          NK  	  pp\	        Wh4       F  w  rV P                  W4       K  	  Kg  	  R# u upi u upi u upi u upi )r   r   N)r'   seedr`   rt   rs   assertIs)r"   r   L_1rU   L_2L_3	optimizedrg   	referenceoptrefs   &&         r   &check_against_PyObject_RichCompareBoolr    s      KKN
NN1
A$C
A4C

AqD7AC
_1I	#)!*<!QAa5!*<#=>#=aqTT#=	>i3JSMM## 4  
 +=>s   CC4C

Cc                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )TestOptimizedComparesi8  c                   ^ R.RR.RR..pV F  pV P                  \        VP                  4       T P                  \        V Uu. uF  q33NK  	  upP                  4       T P                  \        V Uu. uF  q333NK  	  upP                  4       K  	  ^R.RR.R^.RR..pV F  p\        W4       K  	  R# u upi u upi )r   foog        g?N)r              )ra   r   r   r  )r"   heterogeneous_listsr   rU   float_int_listss   &    r   test_safe_object_compare.TestOptimizedCompares.test_safe_object_compare9  s     !5z #U| (%02 %Ai0i):1$):)?)?@i1)=1a4'1)=)B)BC %
 c7!#;7;( !A24; ! *;)=s   B:5B?c           	       aa	  ! VV	3R  lR\         4      p ! R R\        4      p ! R R\        4      o\        ^
4       Uu. uF  q2! V! V4      V.4      NK  	  ppVR,          o	V P                  \        4      ;_uu_ 4        VP                  4        RRR4       \        ^
4       Uu. uF  q2! V! V4      V.4      NK  	  ppVR,          o	V P                  \        4      ;_uu_ 4        V Uu. uF  qU3NK  	  upP                  4        RRR4        ! R R4      pV! 4       V! 4       .pV P                  \        VP
                  4       T P                  \        V Uu. uF  qU3NK  	  upP
                  4       \        \        ^d4      4      R.,           \        ^d4       Uu. uF  p\        V4      NK  	  upR	.,           \        ^d4       Uu. uF  p\        V4      NK  	  up\        ^d4       Uu. uF  p\        R
 4      ! V4      NK  	  up.pV F  p\        W4       K  	  R# u upi   + '       g   i     EL; iu upi u upi   + '       g   i     ELG; iu upi u upi u upi u upi )c                   0   <a  ] tR tRt o VV3R ltRtV tR# )ITestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparatoriN  c                <   < SSn         \        P                  W4      # r    )	__class__rQ   r+   )r"   r)   
WackyList2elems   &&r   r+   PTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparator.__lt__O  s    !+zz$..r   rH   Nr   )r7   r  r  s   @r   WackyComparatorr  N  s     / /r   r  c                       ] tR tRtRtR# )DTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList1iS  rH   N)r1   r2   r3   r4   r5   rH   r   r   
WackyList1r  S  s    r   r  c                   &   a  ] tR tRt o R tRtV tR# )DTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2iV  c                    \         hr    )r   r?   s   &&r   r+   KTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2.__lt__W  s      r   rH   Nr   rC   s   @r   r  r  V  s     ! !r   r  Nc                   &   a  ] tR tRt o R tRtV tR# )MTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparatorif  c                    \         # r    )NotImplementedr?   s   &&r   r+   TTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparator.__lt__g  s    %%r   rH   Nr   rC   s   @r   PointlessComparatorr  f  s     & &r   r!  u   ￿c                 
    W8  # r    rH   r   s   &&r   rL   BTestOptimizedCompares.test_unsafe_object_compare.<locals>.<lambda>r  s    r   r   r  )rQ   r^   r[   ra   r   r   r   r   bytesr   r  )
r"   r  r  r   r   rU   r!  listsr  r  s
   &       @@r   test_unsafe_object_compare0TestOptimizedCompares.test_unsafe_object_compareI  s   
	/ 	/c 	/
	 		! 	! ;@)D)QZ+Q/0)Duz**FFH + ;@)D)QZ+Q/0)Duz**1aT1""$ +
	& 	& !"$7$9:)QVV,)A%6AqdA%6%;%;< eCj!eI-"'*-*Q#a&*-
:$)#J/Jq%(J/:?*E*Q*_-a0*EG A24; 3 E*** E  +** &7
 ./EsN   H#H('H<'I,I7II
 II$.I)
(H9	II	c           	     l    \        T \        ^d4       Uu. uF  p\        V4      NK  	  up4       R# u upi rZ   N)r  r[   r   r   s   & r   test_unsafe_latin_compare/TestOptimizedCompares.test_unsafe_latin_comparev  s8    .t;@:6G;Ea 7:!f;E6G 	H 6G   1
c                Z    \        T \        ^d4       Uu. uF  pVNK  	  up4       R# u upi r)  )r  r[   r   s   & r   test_unsafe_long_compare.TestOptimizedCompares.test_unsafe_long_comparez  s4    .t;@:6G;Ea 78;E6G 	H 6Gs   (
c           	     l    \        T \        ^d4       Uu. uF  p\        V4      NK  	  up4       R# u upi r)  )r  r[   floatr   s   & r   test_unsafe_float_compare/TestOptimizedCompares.test_unsafe_float_compare~  s8    .t;@:6G;Ea 7<Ah;E6G 	H 6Gr,  c           	         \        V \        R 4      .^d,          4       \        T \        ^d4       Uu. uF  p\        R 4      NK  	  up4       R# u upi )nanN)r  r1  r[   )r"   _s   & r   test_unsafe_tuple_compare/TestOptimizedCompares.test_unsafe_tuple_compare  sO     	/teEl^C5GH.t;@:6G;Ea 7<El;E6G 	H 6Gs   A
c                    V P                  \        . ROP                  4       V P                  \        RR.P                  4       V P                  \        RR.P                  4       R# )      ?N))r:  r:  )FA   )rJ   r   )r   rJ   )ra   r   r   r.   s   &r   test_not_all_tuples)TestOptimizedCompares.test_not_all_tuples  sO    )%B%G%GH)h%9%>%>?)h%9%>%>?r   c                J    RR.p\        RR.4      pV P                  W!4       R # )N)Nr   )Nr   )rt   ru   )r"   r   actuals   &  r   test_none_in_tuples)TestOptimizedCompares.test_none_in_tuples  s)    y)I./*r   rH   N)r1   r2   r3   r4   r
  r&  r*  r.  r2  r7  r=  rA  r5   r6   rC   s   @r   r  r  8  s8     < +<ZHHH
H@
+ +r   r  __main__r    )testr   r'   unittest	functoolsr   r	   r   r   TestCaser   r   r   r  r  r1   mainrH   r   r   <module>rI     s        
//
@m1x   m1`!*x   !*JZ&!2!2 Z&z$8^+H-- ^+D zMMO r   