Ë
    èÿæi,  ã                   ó¼   — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlZ G d„ de	«      Z
d„ Zd„ Z G d	„ d
e«      Z G d„ de«      Zedk(  r ej                   «        yy)é    N)Újit)Útypes)ÚTestCasec                   ó   — e Zd Zd„ Zy)ÚDummyc                 ó   — |dz   S )Né   © )ÚselfÚothers     ús/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/tests/test_func_lifetime.pyÚ__add__zDummy.__add__   s   € Ø�q‰yÐó    N)Ú__name__Ú
__module__Ú__qualname__r   r
   r   r   r   r   
   s   „ ór   r   c                 ó   — | dz   S ©Né   r
   ©Úxs    r   Úglobal_usecase1r      s   € Øˆq‰5€Lr   c                  ó   — t         dz   S r   )Ú
global_objr
   r   r   Úglobal_usecase2r      s   € Ü˜‰>Ðr   c                   óX   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zy)ÚTestFuncLifetimezP
    Test the lifetime of compiled function objects and their dependencies.
    c                 ó°   — | j                  t        |j                  «      d«       t        |j                  j	                  «       «      d   }|j
                  S )zV
        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_implzTestFuncLifetime.get_impl   sI   € ð 	×Ñœ˜Z×1Ñ1Ó2°AÔ6Ü�J×(Ñ(×/Ñ/Ó1Ó2°1Ñ5ˆØ×ÑÐr   c                 óŒ  — d„ } t        di |¤Ž|«      }| j                   |d«      d«       | j                  |«      }|||j                  fD �cg c]  }t	        j
                  |«      ‘Œ }}d x}x}x}}t        j                  «        | j                  |D �cg c]	  } |«       ‘Œ c}d gt        |«      z  «       y c c}w c c}w )Nc                 ó   — | dz   S r   r
   r   s    r   Úfz5TestFuncLifetime.check_local_func_lifetime.<locals>.f%   s   € Ø�q‘5ˆLr   r   é   )zint32(int32))
r   ÚassertPreciseEqualr'   Ú__self__ÚweakrefÚrefÚgcÚcollectr   r    )r   Újitargsr*   Úc_fÚcfuncÚobjÚrefsÚwrs           r   Úcheck_local_func_lifetimez*TestFuncLifetime.check_local_func_lifetime$   s¿   € ò	ð -ŒcÑ, GÑ,¨QÓ/ˆØ×Ñ¡ A£¨Ô*à—‘˜cÓ"ˆð ./°°U·^±^Ñ,DÓEÑ,D S”—‘˜CÕ Ð,DˆÐEØ $Ð$ˆÐ$ˆaÐ$�#˜Ü
�
‰
ŒØ×Ñ©Ó.© 2™"�$¨Ñ.°°¼¸T»Ñ0BÕCùò Fùò /s   ÁB<ÂCc                 ó(   — | j                  d¬«       y ©NT)Úforceobj©r8   ©r   s    r   Útest_local_func_lifetimez)TestFuncLifetime.test_local_func_lifetime6   ó   € Ø×&Ñ&°Ð&Õ5r   c                 ó(   — | j                  d¬«       y ©NT)Únopythonr<   r=   s    r   Útest_local_func_lifetime_npmz-TestFuncLifetime.test_local_func_lifetime_npm9   r?   r   c                 ó²  —  t        di |¤Žt        «      }| j                   |d«      d«       | j                  |«      }t	        j
                  |«      }||j                  fD �cg c]  }t	        j
                  |«      ‘Œ }}d x}x}}t        j                  «        | j                  |D �cg c]	  } |«       ‘Œ c}d gt        |«      z  «       y c c}w c c}w )Nr   r+   r
   )r   r   r,   r'   r.   r/   r-   r0   r1   r   r    )r   r2   r3   r4   r7   r5   r6   s          r   Úcheck_global_func_lifetimez+TestFuncLifetime.check_global_func_lifetime<   s»   € ØŒc‰n�G‰nœ_Ó-ˆØ×Ñ¡ A£¨Ô*à—‘˜cÓ"ˆä�[‰[˜ÓˆØ-0°%·.±.Ñ,AÓBÑ,A S”—‘˜CÕ Ð,AˆÐBØ Ð ˆÐ ˆc�EÜ
�
‰
ŒØ×Ñ©Ó.© 2™"�$¨Ñ.°°¼¸T»Ñ0BÕCùò Cùò /s   Á$CÂ+Cc                 ó(   — | j                  d¬«       y r:   ©rE   r=   s    r   Útest_global_func_lifetimez*TestFuncLifetime.test_global_func_lifetimeH   ó   € Ø×'Ñ'°Ð'Õ6r   c                 ó(   — | j                  d¬«       y rA   rG   r=   s    r   Útest_global_func_lifetime_npmz.TestFuncLifetime.test_global_func_lifetime_npmK   rI   r   c                 ól  — t        «       a t        di |¤Žt        «      }| j	                   |«       d«       |t        fD �cg c]  }t        j                  |«      ‘Œ }}d x}x}at        j                  «        | j                  |D �cg c]	  } |«       ‘Œ c}d gt        |«      z  «       y c c}w c c}w )Né   r
   )r   r   r   r   r,   r.   r/   r0   r1   r   r    )r   r2   r3   r5   r6   r7   s         r   Úcheck_global_obj_lifetimez*TestFuncLifetime.check_global_obj_lifetimeN   s¡   € ô
 “Wˆ
àŒc‰n�G‰nœ_Ó-ˆØ×Ñ¡£ qÔ)à-0´*Ñ,=Ó>Ñ,= S”—‘˜CÕ Ð,=ˆÐ>Ø!%Ð%ˆÐ%ˆc�JÜ
�
‰
ŒØ×Ñ©Ó.© 2™"�$¨Ñ.°°¼¸T»Ñ0BÕCùò ?ùò /s   ÁB,ÂB1c                 ó(   — | j                  d¬«       y r:   )rN   r=   s    r   Útest_global_obj_lifetimez)TestFuncLifetime.test_global_obj_lifetime]   r?   r   c                 ó2  ‡— d„ } t        di |¤Ž|«      Š‰j                  «        ˆfd„} t        di |¤Ž|«      }|j                  «        | j                   |d«      d«       |‰||| j                  ‰«      j                  | j                  |«      j                  fD �cg c]  }t        j                  |«      ‘Œ }}dx}x}xŠx}}t        j                  «        | j                  |D �cg c]	  } |«       ‘Œ c}dgt        |«      z  «       yc c}w c c}w )zƒ
        When a jitted function calls into another jitted function, check
        that everything is collected as desired.
        c                 ó   — | dz  S )Né
   r
   )Úas    r   Úmult_10z?TestFuncLifetime.check_inner_function_lifetime.<locals>.mult_10e   s   € Ø�r‘6ˆMr   c                 ó   •—  ‰| dz   «      S )Né   r
   )r   Ú	c_mult_10s    €r   Údo_mathz?TestFuncLifetime.check_inner_function_lifetime.<locals>.do_mathk   s   ø€ Ù˜Q ™UÓ#Ð#r   r   é2   N)z
intp(intp))
r   Údisable_compiler   r'   r-   r.   r/   r0   r1   r    )	r   r2   rU   rY   Ú	c_do_mathr5   ÚwrsÚwrX   s	           @r   Úcheck_inner_function_lifetimez.TestFuncLifetime.check_inner_function_lifetime`   s  ø€ ò
	ð 1”CÑ0¨Ñ0°Ó9ˆ	Ø×!Ñ!Ô#ô	$ð 1”CÑ0¨Ñ0°Ó9ˆ	Ø×!Ñ!Ô#à×Ñ™ 1› rÔ*ð ˜ G¨YØ—‘˜iÓ(×1Ñ1Ø—‘˜iÓ(×1Ñ1ñóñð %(Œw�{‰{˜3Õðð 	ð ð
 ;?Ð>ˆÐ>ˆgÐ>˜	Ð> G¨iÜ
�
‰
ŒØ×Ñ¡sÓ+¡s !™!�# sÑ+¨d¨V´c¸#³hÑ->Õ?ùòùò ,s   Â DÃ+Dc                 ó(   — | j                  d¬«       y r:   ©r_   r=   s    r   Útest_inner_function_lifetimez-TestFuncLifetime.test_inner_function_lifetime|   ó   € Ø×*Ñ*°DÐ*Õ9r   c                 ó(   — | j                  d¬«       y rA   ra   r=   s    r   Ú test_inner_function_lifetime_npmz1TestFuncLifetime.test_inner_function_lifetime_npm   rc   r   N)r   r   r   Ú__doc__r'   r8   r>   rC   rE   rH   rK   rN   rP   r_   rb   re   r
   r   r   r   r      sG   „ ñò òDò$6ò6ò
Dò7ò7òDò6ò@ò8:ó:r   r   c                   ó   — e Zd Zd„ Zy)ÚTestLifeTimeIssuec                 óê   ‡	— ddl m} dd lŠ	|d„ «       }|ˆ	fd„«       }‰	j                  ddggg«      }‰	j                  ddgg«      } |«       } ||d   |«        |«       } ||d   |«        |«       }y )Nr   )Únjitc                 ó6   — |j                   d   }|dk7  r|d   }y)Nr   )Úshape)ÚpointÚpolygonsÚnum_polygonsÚintentionally_unused_variables       r   Úis_point_in_polygonsz@TestLifeTimeIssue.test_double_free.<locals>.is_point_in_polygonsŠ   s%   € à#Ÿ>™>¨!Ñ,ˆLØ˜qÒ à08¸±Ð-Ør   c                  ó>   •— ‰ j                  d‰ j                  ¬«      S )NrS   )Údtype)ÚemptyÚint64)Únps   €r   Údummyz1TestLifeTimeIssue.test_double_free.<locals>.dummy•   s   ø€ à—8‘8˜B b§h¡h�8Ó/Ð/r   r   g      ø¿g      à?)Únumbarj   ÚnumpyÚarray)
r   rj   rq   rw   rn   ÚpointsrT   ÚbÚcrv   s
            @r   Útest_double_freez"TestLifeTimeIssue.test_double_free„   sŽ   ø€ ÝÛð 
ñ	ó 
ð	ð 
ó	0ó 
ð	0ð —8‘8˜q !˜f˜X˜JÓ'ˆØ—‘˜D #˜;˜-Ó(ˆÙ‹GˆÙ˜V A™Y¨Ô1Ù‹Gˆá˜V A™Y¨Ô1Ù‹G‰r   N)r   r   r   r~   r
   r   r   rh   rh   ƒ   s   „ ór   rh   Ú__main__)r0   r.   rx   r   Ú
numba.corer   Únumba.tests.supportr   ÚunittestÚobjectr   r   r   r   rh   r   Úmainr
   r   r   Ú<module>r…      sc   ðÛ 	Û å Ý Ý (Û ôˆFô òòôi:�xô i:ôX˜ô ð@ ˆzÒØ€H‡M�M…Oð r   