+
    :iFN                        R t ^ RIt^ RIt^ RIHt ^ RIHtHtHtH	t	 ^ RI
Ht ^ RIHt ^ RIHtHtHtHt Rt]'       d   ^M^t ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]	P4                  4      t ! R R]4      tR# )z2
Testing C implementation of the numba dictionary
N)TestCase)
_helperlibjittypedtypes)	IS_32BITS)UniTupleModel)register_modeltypeof_implunboxoverloadc                      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R tR tR tR tR tR tR tR tRtV tR# )DictzOA wrapper around the C-API to provide a minimal dictionary object for
testing.
c                V    Wn         W n        W0n        V P                  W#4      V n        R# )z
Parameters
----------
tc : TestCase instance
keysize : int
    byte size for the key
valsize : int
    byte size for the value
N)tckeysizevalsizedict_new_minsizedp)selfr   r   r   s   &&&&W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/tests/test_dictimpl.py__init__Dict.__init__   s%     ''9    c                P    V P                   P                  V P                  4       R # N)r   numba_dict_freer   r   s   &r   __del__Dict.__del__(   s    (r   c                "    V P                  4       # r   )dict_lengthr   s   &r   __len__Dict.__len__+   s    !!r   c                H   \        VP                  4       4      p\        VP                  4       4      pV P                  P                  \	        V4      V P
                  4       V P                  P                  \	        V4      V P                  4       V P                  W44       R # r   )bytesencoder   assertEquallenr   r   dict_insert)r   kvbkbvs   &&&  r   __setitem__Dict.__setitem__.   sh    188:188:CGT\\2CGT\\2 r   c                    \        VP                  4       4      pV P                  P                  \	        V4      V P
                  4       V P                  V4      w  r4V\        8X  d   \        hVP                  4       # r   )
r%   r&   r   r'   r(   r   dict_lookup
DKIX_EMPTYKeyErrordecode)r   r*   r,   ixolds   &&   r   __getitem__Dict.__getitem__5   sY    188:CGT\\2""2&N::<r   c                    \        VP                  4       4      pV P                  P                  \	        V4      V P
                  4       V P                  V4      '       g   \        V4      hR # r   )r%   r&   r   r'   r(   r   dict_delitemr3   )r   r*   r,   s   && r   __delitem__Dict.__delitem__>   sN    188:CGT\\2  $$1+ %r   c                8     W,          #   \          d     R # i ; ir   )r3   )r   r*   s   &&r   getDict.getD   s     	7N 		s   
 c                    \        V 4      # r   )DictIterr   s   &r   items
Dict.itemsJ   s    ~r   c                f    V P                  4       w  rVP                  4       VP                  4       3# r   )dict_popitemr4   )r   r*   r+   s   &  r   popitemDict.popitemM   s)      "xxz188:%%r   c                    \         P                  ! 4       pV P                  P                  \         P                  ! V4      ^ W4      pV P                  P                  V^ 4       V#     )ctypesc_void_pr   numba_dict_new_sizedbyrefr'   )r   key_sizeval_sizer   statuss   &&&  r   r   Dict.dict_new_minsizeU   sM    __--LLa
 	FA&	r   c                L    V P                   P                  V P                  4      # r   )r   numba_dict_lengthr   r   s   &r   r!   Dict.dict_length]   s    ww((11r   c                    \        V4      pV P                  P                  V P                  WV4      pV P                  P	                  V^ 4       R# rJ   N)hashr   numba_dict_insert_ezr   assertGreaterEqual)r   	key_bytes	val_byteshashvalrQ   s   &&&  r   r)   Dict.dict_insert`   s@    y/--GGY
 	""61-r   c                    \        V4      p\        P                  ! V P                  4      pV P                  P                  V P                  WV4      pV P                  P                  V\        4       WCP                  3# r   )
rX   rK   create_string_bufferr   r   numba_dict_lookupr   rZ   r2   value)r   r[   r]   oldval_bytesr5   s   &&   r   r1   Dict.dict_lookupg   sc    y/224<<@WW&&GGY
 	""2z2%%%%r   c                    V P                  V4      w  r#V\        8X  d   R # \        V4      pV P                  P	                  V P
                  WB4      pV P                  P                  V^ 4       R# )FT)r1   r2   rX   r   numba_dict_delitemr   r'   )r   r[   r5   oldvalr]   rQ   s   &&    r   r:   Dict.dict_delitemp   sY    %%i0
y/++DGGWAFA&r   c                f   \         P                  ! V P                  4      p\         P                  ! V P                  4      pV P                  P                  V P                  W4      pV^ 8w  d.   VR8X  d   \        R4      hV P                  P                  R4       VP                  VP                  3# )rJ   popitem(): dictionary is emptyUnknown)
rK   r`   r   r   r   numba_dict_popitemr   r3   _failrb   )r   r[   r\   rQ   s   &   r   rE   Dict.dict_popitemy   s    //=	//=	++DGGYJQ;|?@@i(	//r   c                P    V P                   P                  WP                  4       R # r   )r   numba_dict_iterr   )r   itptrs   &&r   	dict_iterDict.dict_iter   s    ww/r   c                6   \         P                  ! ^ 4      p\         P                  ! ^ 4      pV P                  P                  V\         P                  ! V4      \         P                  ! V4      4      pVR8X  d   \        R4      hVR8X  d   R# V P                  P                  V^ 4       V P                  P                  VP                  \        ,          ^ RR7       V P                  P                  VP                  \        ,          ^ RR7       \         P                  V P                  ,          P                  VP                  4      p\         P                  V P                  ,          P                  VP                  4      pVP                  VP                  3# )rJ   zdictionary mutatedNzkey not aligned)msgzval not aligned)rK   rL   r   numba_dict_iter_nextrN   
ValueErrorrZ   r'   rb   ALIGNc_charr   from_addressr   )r   rr   r,   r-   rQ   keyvals   &&     r   dict_iter_nextDict.dict_iter_next   s   __Q__Q--6<<#V\\"%5
 R<122r\GG&&vq1
 GG5 0!9JKGG5 0!9JK==4<</==bhhGC==4<</==bhhGC99cii''r   )r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r"   r.   r7   r;   r>   rB   rF   r   r!   r)   r1   r:   rE   rs   r   __static_attributes____classdictcell____classdict__s   @r   r   r      sd     :)"! &2.&	00( (r   r   c                   :   a  ] tR t^t o RtR tR tR t]tRt	V t
R# )rA   zA iterator for the `Dict.items()`.

Only the `.items()` is needed.  `.keys` and `.values` can be trivially
implemented on the `.items` iterator.
c                P   Wn         V P                   P                  P                  4       p\        P                  V,          ! ^ 4      V n        \        P                  ! V P
                  \        P                  4      V n        V P                   P                  V P                  4       R# rW   )
parentr   numba_dict_iter_sizeofrK   c_char_pit_state_bufcastrL   itrs   )r   r   itsizes   && r   r   DictIter.__init__   se    668#__v5q9++d//Adgg&r   c                    V # r    r   s   &r   __iter__DictIter.__iter__   s    r   c                    V P                   P                  V P                  4      pVf   \        hVw  r#VP	                  4       VP	                  4       3# r   )r   r   r   StopIterationr4   )r   outr*   r+   s   &   r   __next__DictIter.__next__   sC    kk((1;DA88:qxxz))r   )r   r   r   N)r   r   r   r   r   r   r   r   nextr   r   r   s   @r   rA   rA      s      
'* Dr   rA   c                   *   a  ] tR t^t o RtR tRtV tR# )Parametrizedz[supporting type for TestDictImpl.test_parametrized_types
needs to be global to be cacheablec                ~    \         ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       g   Q hR# )c              3   B   "   T F  p\        V\        4      x  K  	  R # 5ir   )
isinstancestr).0r+   s   & r   	<genexpr>(Parametrized.__init__.<locals>.<genexpr>   s     3s!:a%%ss   FTN)all)r   tups   &&r   r   Parametrized.__init__   s)    s3s3sss3s33333r   r   N)r   r   r   r   r   r   r   r   r   s   @r   r   r      s     *4 4r   r   c                   L   a a ] tR t^t oRtV 3R lt]R 4       tR tRt	Vt
V ;t# )ParametrizedTypezQthis is essentially UniTuple(unicode_type, n)
BUT type name is the same for all nc                x   < \         \        V `  R 4       \        P                  V n        \        V4      V n        R# )r   N)superr   r   r   unicode_typedtyper(   n)r   rb   	__class__s   &&r   r   ParametrizedType.__init__   s,    ./AB''
Ur   c                    V P                   # r   r   r   s   &r   r~   ParametrizedType.key   s    vvr   c                    V P                   # r   r   r   s   &r   r"   ParametrizedType.__len__   s    vvr   )r   r   )r   r   r   r   r   r   propertyr~   r"   r   r   __classcell__)r   r   s   @@r   r   r      s-     +
   r   r   c                   x   a  ] tR t^t o R tR tR tR tR tR t	RR lt
R tR	 tR
 tR tR tR tR tRtV tR# )TestDictImplc           	        \         P                  p\         P                  p\         P                  pRR lpV! R\         P                  4      V n        V! R\         P                  \         P
                  ! V4      \         P                  \         P                  \         P                  .4      V n        V! RRV.4      V n        V! R\         P                  V.4      V n        V! R\         P                  V\         P                  V\         P                  .4      V n
        V! R\         P                  V\         P                  V\         P                  .4      V n        V! R	\         P                  VV\         P                  .4      V n        V! R
\         P                  V\         P                  \         P                  .4      V n        V! R\         P                  4      V n        V! RRVV.4      V n        V! R\         P                  V\         P
                  ! \         P                  4      \         P
                  ! \         P                  4      .4      V n        R# )zEBind to the c_helper library and provide the ctypes wrapper.
        c                 l    \         P                  ! V.VO5!  pV! \        P                  V ,          4      # r   )rK   	CFUNCTYPEr   	c_helpers)namerestypeargtypesprotos   &&& r   wrap TestDictImpl.setUp.<locals>.wrap   s-    $$W8x8E--d344r   	test_dictdict_new_sized	dict_freeNr!   dict_insert_ezr1   r:   rE   dict_iter_sizeofrs   r   )r   )rK   rL   	c_ssize_tc_intnumba_test_dictPOINTERrM   r   rT   r   rY   ra   rf   rm   c_size_tr   rq   ry   )r   dict_titer_thash_tr   s   &    r   setUpTestDictImpl.setUp   s    !!	5
  $LL 
 %)LLv&      		%
!  $H 
 "&H"
 %)LL		%
!  "&		"
 #'LL  #
 #'LL#
 '+OO'
#  $ 
 %)LLv/v/%
!r   c                J    V P                  4       pV P                  V^ 4       R# rW   )r   r'   )r   rets   & r   test_simple_c_testTestDictImpl.test_simple_c_test[  s     ""$a r   c                4   \        V ^^4      pV P                  \        V4      ^ 4       V P                  VP	                  R4      4       RVR&   V P                  \        V4      ^4       V P                  VP	                  R4      4       V P                  VR,          R4       RVR&   V P                  \        V4      ^4       V P                  VR,          R4       RVR&   V P                  \        V4      ^4       V P                  VR,          R4       V P                  VR,          R4       RVR&   V P                  \        V4      ^4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R4       R# )	   abcdbeefcafecafe0000cafe0001abcecafe0002abcfN)r   r'   r(   assertIsNoner>   assertIsNotNoner   ds   & r   test_insertion_small!TestDictImpl.test_insertion_small`  sX   q!Q#!%%-( &	Q#QUU6]+6J/ &	Q#6J/ &	Q#6J/6J/ &	Q#6J/6J/6J/r   c                    \        V ^^4      pR pR p\        V4       F5  pV! V4      W#! V4      &   V P                  \        V4      V^,           4       K7  	  \        V4       F'  pV P                  W#! V4      ,          V! V4      4       K)  	  R# )   c                 $    R P                  V 4      # )z	key_{:04}formatr+   s   &r   make_key3TestDictImpl.check_insertion_many.<locals>.make_key      %%a((r   c                 $    R P                  V 4      # )z	val_{:04}r   r   s   &r   make_val3TestDictImpl.check_insertion_many.<locals>.make_val  r   r   N)r   ranger'   r(   )r   nmaxr   r   r   is   &&    r   check_insertion_many!TestDictImpl.check_insertion_many~  s    q!	)	) tA%a[AhqkNSVQU+ 
 tAQx{^Xa[9 r   c                   V P                  ^R7       V P                  ^R7       V P                  ^	R7       V P                  ^R7       V P                  ^ R7       V P                  ^!R7       V P                  RR7       V P                  RR7       V P                  RR7       V P                  RR7       V P                  RR7       V P                  RR7       R# )	   )r   i     i  i  i   i  N)r   r   s   &r   test_insertion_many TestDictImpl.test_insertion_many  s     	!!q!)!!q!)!!q!)!!r!*!!r!*!!r!*!!t!,!!t!,!!t!,!!t!,!!t!,!!t!,r   c                   \        V ^^4      pV P                  \        V4      ^ 4       V P                  VP	                  R4      4       RVR&   RVR&   RVR&   V P                  \        V4      ^4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R4       V P                  \        V4      ^4       VR V P                  VP	                  R4      4       V P                  VR,          R4       V P                  VR,          R4       V P                  \        V4      ^4       V P                  \        4      ;_uu_ 4        VR RRR4       VR V P                  VP	                  R4      4       V P                  VR,          R4       V P                  VP	                  R4      4       V P                  \        V4      ^4       VR V P                  VP	                  R4      4       V P                  VP	                  R4      4       V P                  VP	                  R4      4       V P                  \        V4      ^ 4       R#   + '       g   i     EL; i)r   r   r   r   r   r   r   N)r   r'   r(   r   r>   assertRaisesr3   r   s   & r   test_deletion_small TestDictImpl.test_deletion_small  s   q!Q#!%%-(&	&	&	Q#6J/6J/6J/Q# fI!%%-(6J/6J/Q# x((&	 ) fI!%%-(6J/!%%-(Q# fI!%%-(!%%-(!%%-(Q# )((s   &I))I:	c                   \         P                  ! V4       \        V ^^4      p/ pR pR p\        V4       F  p	V! V	4      WW! V	4      &   K  	  \        V4       F/  p	V! V	4      p
V! V	4      pWV
&   V P	                  WZ,          V4       K1  	  V P	                  \        V4      V4       \         P                  ! \        V4      V4      pVP                  4       p\        V^R7       F*  w  rWZ W V P	                  \        V4      W,
          4       K,  	  V P	                  \        V4      W,
          4       V F#  p
V P                  VP                  V
4      4       K%  	  V F!  p
V P	                  WZ,          W,          4       K#  	  \        V4       F'  p	V! W,           4      p
V! W,           4      pWV
&   WV
&   K)  	  V P	                  \        V4      \        V4      4       V F!  p
V P	                  WZ,          W,          4       K#  	  R# )r   c                 $    R P                  V 4      # zk_{:06x}r   r   s   &r   r   4TestDictImpl.check_delete_randomly.<locals>.make_key      $$Q''r   c                 $    R P                  V 4      # zv_{:06x}r   r   s   &r   r   4TestDictImpl.check_delete_randomly.<locals>.make_val  r  r   )startN)randomseedr   r   r'   r(   samplelistcopy	enumerater   r>   )r   r   ndropnrefillr  r   keysr   r   r   r*   r+   droplistremains   &&&&&         r   check_delete_randomly"TestDictImpl.check_delete_randomly  s   Dq!	(	( tA%a[AhqkN  tAAAGQT1%	  	Q& ==dU3ha0DA	SVTX. 1 	Q. AaeeAh'  AQT69-  wA"A"A1IaD	   	Vc!f- AQT69- r   c                   V P                  ^^^R7       V P                  ^^
^R7       V P                  ^d^2^R7       V P                  ^d^c^dR7       V P                  ^d^d^dR7       V P                  RR^R7       V P                  RRRR7       R# )r   r   r  r  r   i  i   Nr  r   s   &r   test_delete_randomly!TestDictImpl.test_delete_randomly  s    ""A">"""b"A""2s"C""2s"C""3"D""C"C""C"Fr   c                .    V P                  RRRR7       R# )   r  Ni   i   r   r  r   s   &r   test_delete_randomly_large'TestDictImpl.test_delete_randomly_large  s    
 	""UE"Jr   c                   ^
p\        V ^^4      pR pR p\        V4       F  pV! V4      W#! V4      &   K  	  V P                  \        V4      V4       VP	                  4       w  rgV P                  \        V4      V^,
          4       V P                  Wc! \        V4      4      4       V P                  Wt! \        V4      4      4       \        V4      '       d   \        V4      pVP	                  4       w  rgV P                  \        V4      V^,
          4       V P                  Wc! \        V4      4      4       V P                  Wt! \        V4      4      4       K  V P                  \        V4      ^ 4       V P                  \        4      ;_uu_ 4       p	VP	                  4        RRR4       V P                  R\        X	P                  4      4       R#   + '       g   i     L7; i)
   c                 $    R P                  V 4      # r  r   r   s   &r   r   +TestDictImpl.test_popitem.<locals>.make_key  r  r   c                 $    R P                  V 4      # r	  r   r   s   &r   r   +TestDictImpl.test_popitem.<locals>.make_val  r  r   Nrj   )
r   r   r'   r(   rF   r   r3   assertInr   	exception)
r   r   r   r   r   r   r*   r+   r   raisess
   &         r   test_popitemTestDictImpl.test_popitem  sq   q!	(	( tA%a[AhqkN  	Q&yy{Q*HSV,-HSV,-!ffAA99;DASVQU+QQ 01QQ 01Q#x((FIIK ),  !	
 )(s   GG!	c                &  a \        V ^^4      pRoR pV3R lp\        S4       F  pV! V4      W! V4      &   K  	  \        VP                  4       4       F8  w  pw  rVV P	                  V! V4      V4       V P	                  V! V4      V4       K:  	  R# )r   i  c                 $    R P                  V 4      # z{:04}r   r   s   &r   r   .TestDictImpl.test_iter_items.<locals>.make_key<  s    >>!$$r   c                 4   < R P                  V S,           4      # r/  r   )r+   r   s   &r   r   .TestDictImpl.test_iter_items.<locals>.make_val?  s    >>!d(++r   Nr   r   r  rB   r'   )r   r   r   r   r   r*   r+   r   s   &      @r   test_iter_itemsTestDictImpl.test_iter_items7  s    q!	%	, tA%a[AhqkN  #1779-IAvXa[!,Xa[!, .r   c                .  aaa \        V SS4      pV3R  lpVV3R lp\        S4       F  pV! V4      WE! V4      &   K  	  \        VP                  4       4       F8  w  pw  rV P	                  V! V4      V4       V P	                  V! V4      V	4       K:  	  R# )c                 .   < R P                  V S4      RS # z{:0{}}Nr   )r+   rO   s   &r   r   +TestDictImpl.check_sizing.<locals>.make_keyN  s    ??1h/	::r   c                 J   < R P                  SV ,
          ^,
          S4      RS # r8  r   )r+   r   rP   s   &r   r   +TestDictImpl.check_sizing.<locals>.make_valQ  s#    ??4!8a<:9HEEr   Nr3  )
r   rO   rP   r   r   r   r   r   r*   r+   s
   &fff      r   check_sizingTestDictImpl.check_sizingJ  s    x*	;	F tA%a[AhqkN  #1779-IAvXa[!,Xa[!, .r   c                `    \        ^^4       F  pV P                  W^V,          R7       K  	  R# )   )rO   rP   r   N)r   r<  )r   r   s   & r   test_sizingTestDictImpl.test_sizing\  s)    q!Aq1a4@ r   c                  a \        \        4      ! \        4       \        P                  ! \
        4      R 4       p\        \        4      R 4       pR o\        S4      R 4       p\        RRR7      V3R l4       p\        R	4      \        R
4      reV! WV4       VP                  4       ! 4        VP                  4        VP                  P                  4        \        ^24       F  pV P                  V! WV4      4       K  	  R# )z*https://github.com/numba/numba/issues/6401c                     \        V 4      # r   )r   )r   cs   &&r   typeof_unit:TestDictImpl.test_parameterized_types.<locals>.typeof_unitf  s    #C((r   c                 v    VP                  \        P                  ! V P                  \	        V 4      4      V4      # r   )r   r   UniTupler   r(   )typobjcontexts   &&&r   unbox_parametrizedATestDictImpl.test_parameterized_types.<locals>.unbox_parametrizedj  s&    ==		3s8!DcJJr   c                     Q hrI   r   r   s   &r   dict_vs_cache_vs_parametrizedLTestDictImpl.test_parameterized_types.<locals>.dict_vs_cache_vs_parametrizedn  s    1r   c                    a V oV3R  lpV# )c                 l   < \         P                  P                  \        P                  S4      pWR &   R# )dataN)r   r   emptyr   r   )r+   r   rI  s   & r   %objmode_vs_cache_vs_parametrized_impl~TestDictImpl.test_parameterized_types.<locals>.ol_dict_vs_cache_vs_parametrized.<locals>.objmode_vs_cache_vs_parametrized_implu  s&    JJ$$U%7%7=&	r   r   )r+   rU  rI  s   & @r    ol_dict_vs_cache_vs_parametrizedOTestDictImpl.test_parameterized_types.<locals>.ol_dict_vs_cache_vs_parametrizedq  s    C
 98r   T)nopythoncachec                 (   < S! V 4       S! V4       R # r   r   )xyrO  s   &&r   set_parametrized_dataDTestDictImpl.test_parameterized_types.<locals>.set_parametrized_data|  s     *!,)!,r   N)ab)r`  )r	   r   r   r
   registerr   r   r   r   _make_finalizer_reset_overloads	targetctxinitr   r   )	r   rE  rL  rW  r^  r\  r]  iirO  s	   &       @r   test_parameterized_types%TestDictImpl.test_parameterized_typesa  s     	'(7			l	+	) 
,	) 
	 	K 
!	K	 
/	0	9 
1	9 
d$	'	- 
(	- J'f)=1a# 	--/1..0'',,.)B3A9: r   )rf   r   rY   rq   ry   r   rT   ra   rM   rm   r   NrI   )r   r   r   r   r   r   r   r   r   r  r  r  r   r+  r4  r<  r@  rh  r   r   r   s   @r   r   r      sX     F
P!
0<:&-&'$R5.nGK 
D-&-$A
/; /;r   r   )r   rK   r  numba.tests.supportr   numbar   r   r   r   numba.core.configr   numba.core.datamodel.modelsr   numba.extendingr	   r
   r   r   r2   r{   objectr   rA   tupler   Typer   r   r   r   r   <module>rs     s~      ( / / ' 5 H H 
 AG(6 G(Tv 645 4uzz "~;8 ~;r   