
    sh,                         S SK r S SKrS SKJr  S SKJr  S SKJr  S SKr " S S\	5      r
S rS r " S	 S
\5      r " S S\5      r\S:X  a  \R                   " 5         gg)    N)jit)types)TestCasec                       \ rS rSrS rSrg)Dummy
   c                     US-   $ )N    )selfothers     r/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/tests/test_func_lifetime.py__add__Dummy.__add__   s    qy    r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   
   s    r   r   c                     U S-   $ N   r   xs    r   global_usecase1r      s    q5Lr   c                      [         S-   $ r   )
global_objr   r   r   global_usecase2r      s    >r   c                   `    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rSrg)TestFuncLifetime   zH
Test the lifetime of compiled function objects and their dependencies.
c                     U R                  [        UR                  5      S5        [        UR                  R	                  5       5      S   nUR
                  $ )zF
Get the single implementation (a C function object) of a dispatcher.
r   r   )assertEquallen	overloadslistvaluesentry_point)r   
dispatchercress      r   get_implTestFuncLifetime.get_impl   sI     	Z112A6J((//1215r   c                    S n[        S0 UD6" U5      nU R                  U" S5      S5        U R                  U5      nX#UR                  4 Vs/ s H  n[        R
                  " U5      PM     nnS =n=n=p4[        R                  " 5         U R                  U Vs/ s H	  ow" 5       PM     snS /[        U5      -  5        g s  snf s  snf )Nc                     U S-   $ r   r   r   s    r   f5TestFuncLifetime.check_local_func_lifetime.<locals>.f%   s    q5Lr   r      )zint32(int32))
r   assertPreciseEqualr,   __self__weakrefrefgccollectr$   r%   )r   jitargsr0   c_fcfuncobjrefswrs           r   check_local_func_lifetime*TestFuncLifetime.check_local_func_lifetime$   s    	 ,G,Q/A*c" ./U^^,DE,DSC ,DE $$$a$#


.2"$.T0BC F /s    CCc                 "    U R                  SS9  g NT)forceobjr?   r   s    r   test_local_func_lifetime)TestFuncLifetime.test_local_func_lifetime6       &&&5r   c                 "    U R                  SS9  g NT)nopythonrD   rE   s    r   test_local_func_lifetime_npm-TestFuncLifetime.test_local_func_lifetime_npm9   rH   r   c                    [        S0 UD6" [        5      nU R                  U" S5      S5        U R                  U5      n[        R
                  " U5      nX#R                  4 Vs/ s H  n[        R
                  " U5      PM     nnS =n=p#[        R                  " 5         U R                  U Vs/ s H	  oD" 5       PM     snS /[        U5      -  5        g s  snf s  snf )Nr   r2   r   )r   r   r3   r,   r5   r6   r4   r7   r8   r$   r%   )r   r9   r:   r;   r>   r<   r=   s          r   check_global_func_lifetime+TestFuncLifetime.check_global_func_lifetime<   s    nGn_-A*c"[[-0..,AB,ASC ,AB   c


.2"$.T0BC C /s   $ C/Cc                 "    U R                  SS9  g rB   rO   rE   s    r   test_global_func_lifetime*TestFuncLifetime.test_global_func_lifetimeH       '''6r   c                 "    U R                  SS9  g rJ   rR   rE   s    r   test_global_func_lifetime_npm.TestFuncLifetime.test_global_func_lifetime_npmK   rU   r   c                 z   [        5       q[        S0 UD6" [        5      nU R	                  U" 5       S5        U[        4 Vs/ s H  n[
        R                  " U5      PM     nnS =n=nq[        R                  " 5         U R                  U Vs/ s H	  oU" 5       PM     snS /[        U5      -  5        g s  snf s  snf )N   r   )r   r   r   r   r3   r5   r6   r7   r8   r$   r%   )r   r9   r:   r<   r=   r>   s         r   check_global_obj_lifetime*TestFuncLifetime.check_global_obj_lifetimeN   s    
 W
nGn_-q)-0*,=>,=SC ,=>!%%%cJ


.2"$.T0BC ? /s    B3B8c                 "    U R                  SS9  g rB   )r[   rE   s    r   test_global_obj_lifetime)TestFuncLifetime.test_global_obj_lifetime]   rH   r   c                 >  ^ S n[        S0 UD6" U5      mTR                  5         U4S jn[        S0 UD6" U5      nUR                  5         U R                  U" S5      S5        UTX4U R                  T5      R                  U R                  U5      R                  4 Vs/ s H  n[
        R                  " U5      PM     nnS=n=n=m=p4[        R                  " 5         U R                  U Vs/ s H	  ow" 5       PM     snS/[        U5      -  5        gs  snf s  snf )zk
When a jitted function calls into another jitted function, check
that everything is collected as desired.
c                     U S-  $ )Nr   r   )as    r   mult_10?TestFuncLifetime.check_inner_function_lifetime.<locals>.mult_10e   s    r6Mr   c                    > T" U S-   5      $ )N   r   )r   	c_mult_10s    r   do_math?TestFuncLifetime.check_inner_function_lifetime.<locals>.do_mathk   s    QU##r   r   2   N)z
intp(intp))
r   disable_compiler$   r,   r4   r5   r6   r7   r8   r%   )	r   r9   rc   rh   	c_do_mathr<   wrswrg   s	           @r   check_inner_function_lifetime.TestFuncLifetime.check_inner_function_lifetime`   s   
	 009	!!#	$ 009	!!#1r* Gi(11i(11 %(w{{3 	 
 ;?>>g>	>G


s+s!!#s+dVc#h->? ,s     D/Dc                 "    U R                  SS9  g rB   ro   rE   s    r   test_inner_function_lifetime-TestFuncLifetime.test_inner_function_lifetime|       **D*9r   c                 "    U R                  SS9  g rJ   rr   rE   s    r    test_inner_function_lifetime_npm1TestFuncLifetime.test_inner_function_lifetime_npm   ru   r   r   N)r   r   r   r   __doc__r,   r?   rF   rL   rO   rS   rW   r[   r^   ro   rs   rw   r   r   r   r   r!   r!      sG     D$66
D77D6@8::r   r!   c                       \ rS rSrS rSrg)TestLifeTimeIssue   c                    ^	 SSK Jn  SS Km	US 5       nUU	4S j5       nT	R                  SS///5      nT	R                  SS//5      nU" 5       nU" US   U5        U" 5       nU" US   U5        U" 5       ng )Nr   )njitc                 8    UR                   S   nUS:w  a  US   ng)Nr   )shape)pointpolygonsnum_polygonsintentionally_unused_variables       r   is_point_in_polygons@TestLifeTimeIssue.test_double_free.<locals>.is_point_in_polygons   s%    #>>!,Lq 08-r   c                  8   > T R                  ST R                  S9$ )Nr   )dtype)emptyint64)nps   r   dummy1TestLifeTimeIssue.test_double_free.<locals>.dummy   s    88Bbhh8//r   r   g      g      ?)numbar~   numpyarray)
r   r~   r   r   r   pointsrb   bcr   s
            @r   test_double_free"TestLifeTimeIssue.test_double_free   s     
	 
	 
	0 
	0 88q!fXJ'D#;-(GVAY1GVAY1Gr   r   N)r   r   r   r   r   r   r   r   r   r{   r{      s    r   r{   __main__)r7   r5   r   r   
numba.corer   numba.tests.supportr   unittestobjectr   r   r   r!   r{   r   mainr   r   r   <module>r      sa    	    ( F i:x i:X @ zMMO r   