§
    ƒÛgæ[  ã                   óŽ  — d Z ddlmZmZ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dlZddlZddlZddlZddlZddlmZ ddlZddlmZ ddlmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ d„ Z  G d„ de¬¦  «        Z! G d„ de!¦  «        Z" G d„ de¬¦  «        Z# G d„ de$¦  «        Z% G d„ de%e#¦  «        Z& G d„ de%e#¦  «        Z' G d„ de%e#¦  «        Z( G d„ de#¦  «        Z) G d„ de¬¦  «        Z* G d„ d e*¦  «        Z+ G d!„ d"e*¦  «        Z, G d#„ d$e$¦  «        Z- G d%„ d&e!¦  «        Z. G d'„ d(e.¦  «        Z/ e0d)g¦  «        Z1d*„ Z2dS )+z+
Caching mechanism for compiled functions.
é    )ÚABCMetaÚabstractmethodÚabstractpropertyN)ÚAppDirs)ÚNumbaWarning)ÚBaseContext)ÚCodeLibrary)ÚCompileResult)ÚconfigÚcompiler©Údumpsc                 óJ   — t           j        r| |z  } t          | ¦  «         d S d S ©N)r   ÚDEBUG_CACHEÚprint)ÚmsgÚargss     úH/granary/edev/quantum/lib/python3.11/site-packages/numba/core/caching.pyÚ
_cache_logr      s/   € ÝÔð Ø�D‰jˆÝˆc‰
Œ
ˆ
ˆ
ˆ
ðð ó    c                   ó’   — e Zd Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
dS )Ú_Cachec                 ó   — dS )zW
        The base filesystem path of this cache (for example its root folder).
        N© ©Úselfs    r   Ú
cache_pathz_Cache.cache_path&   ó   € € € r   c                 ó   — dS )zµ
        Load an overload for the given signature using the target context.
        The saved object must be returned if successful, None if not found
        in the cache.
        Nr   ©r   ÚsigÚtarget_contexts      r   Úload_overloadz_Cache.load_overload,   r   r   c                 ó   — dS )z<
        Save the overload for the given signature.
        Nr   ©r   r"   Údatas      r   Úsave_overloadz_Cache.save_overload4   r   r   c                 ó   — dS )z#
        Enable the cache.
        Nr   r   s    r   Úenablez_Cache.enable:   r   r   c                 ó   — dS )z$
        Disable the cache.
        Nr   r   s    r   Údisablez_Cache.disable@   r   r   c                 ó   — dS )z"
        Flush the cache.
        Nr   r   s    r   Úflushz_Cache.flushF   r   r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r$   r(   r*   r,   r.   r   r   r   r   r   $   sµ   € € € € € àðð ñ Ôðð
 ðð ñ „^ðð ðð ñ „^ðð
 ðð ñ „^ðð
 ðð ñ „^ðð
 ðð ñ „^ðð ð r   r   )Ú	metaclassc                   óB   — e Zd Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )Ú	NullCachec                 ó   — d S r   r   r   s    r   r   zNullCache.cache_pathN   s   € àˆtr   c                 ó   — d S r   r   r!   s      r   r$   zNullCache.load_overloadR   ó   € Øˆr   c                 ó   — d S r   r   )r   r"   Úcress      r   r(   zNullCache.save_overloadU   r7   r   c                 ó   — d S r   r   r   s    r   r*   zNullCache.enableX   r7   r   c                 ó   — d S r   r   r   s    r   r,   zNullCache.disable[   r7   r   c                 ó   — d S r   r   r   s    r   r.   zNullCache.flush^   r7   r   N)
r/   r0   r1   Úpropertyr   r$   r(   r*   r,   r.   r   r   r   r4   r4   M   sx   € € € € € Øðð ñ „Xððð ð ðð ð ðð ð ðð ð ðð ð ð ð r   r4   c                   ó†   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Ze	d„ ¦   «         Z
e	d„ ¦   «         ZdS )	Ú_CacheLocatorz<
    A filesystem locator for caching a given function.
    c                 ó¨   — |                       ¦   «         }t          j        |d¬¦  «         t          j        |¬¦  «                             ¦   «          d S )NT)Úexist_ok)Údir)Úget_cache_pathÚosÚmakedirsÚtempfileÚTemporaryFileÚclose)r   Úpaths     r   Úensure_cache_pathz_CacheLocator.ensure_cache_pathg   sN   € Ø×"Ò"Ñ$Ô$ˆÝ
Œ�D 4Ð(Ñ(Ô(Ð(åÔ 4Ð(Ñ(Ô(×.Ò.Ñ0Ô0Ð0Ð0Ð0r   c                 ó   — dS )zA
        Return the directory the function is cached in.
        Nr   r   s    r   rC   z_CacheLocator.get_cache_pathm   r   r   c                 ó   — dS )z{
        Get a timestamp representing the source code's freshness.
        Can return any picklable Python object.
        Nr   r   s    r   Úget_source_stampz_CacheLocator.get_source_stamps   r   r   c                 ó   — dS )z™
        Get a string disambiguator for this locator's function.
        It should allow disambiguating different but similarly-named functions.
        Nr   r   s    r   Úget_disambiguatorz_CacheLocator.get_disambiguatorz   r   r   c                 ó   — t           ‚)ze
        Create a locator instance for the given function located in the
        given file.
        )ÚNotImplementedError)ÚclsÚpy_funcÚpy_files      r   Úfrom_functionz_CacheLocator.from_function�   s
   € õ "Ð!r   c                 óf  — t           j                             |¦  «        }t           j                             |¦  «        }t           j                             |¦  «        d         }t          j        |                     ¦   «         ¦  «                             ¦   «         }d 	                    ||g¦  «        S )zâGiven the Python file path, compute a suitable path inside the
        cache directory.

        This will reduce a file path that is too long, which can be a problem
        on some operating system (i.e. Windows 7).
        éÿÿÿÿÚ_)
rD   rI   ÚabspathÚdirnameÚsplitÚhashlibÚsha1ÚencodeÚ	hexdigestÚjoin)rR   rT   rI   ÚsubpathÚ	parentdirÚhasheds         r   Úget_suitable_cache_subpathz(_CacheLocator.get_suitable_cache_subpath‰   s€   € õ Œw�Š˜wÑ'Ô'ˆÝ”'—/’/ $Ñ'Ô'ˆÝ”G—M’M 'Ñ*Ô*¨2Ô.ˆ	õ ”˜gŸnšnÑ.Ô.Ñ/Ô/×9Ò9Ñ;Ô;ˆà�xŠx˜ FÐ+Ñ,Ô,Ð,r   N)r/   r0   r1   Ú__doc__rJ   r   rC   rM   rO   ÚclassmethodrU   rd   r   r   r   r?   r?   b   s´   € € € € € ðð ð1ð 1ð 1ð ðð ñ „^ðð
 ðð ñ „^ðð ðð ñ „^ðð ð"ð "ñ „[ð"ð ð-ð -ñ „[ð-ð -ð -r   r?   c                   ó4   — e Zd ZdZd„ Zd„ Zed„ ¦   «         ZdS )Ú_SourceFileBackedLocatorMixinzf
    A cache locator mixin for functions which are backed by a well-known
    Python source file.
    c                 óº   — t          t          dd¦  «        rt          j        t          j        ¦  «        }nt          j        | j        ¦  «        }|j        |j        fS ©NÚfrozenF)ÚgetattrÚsysrD   ÚstatÚ
executableÚ_py_fileÚst_mtimeÚst_size)r   Ústs     r   rM   z._SourceFileBackedLocatorMixin.get_source_stamp¡   sK   € Ý•3˜ %Ñ(Ô(ð 	(Ý”�œÑ(Ô(ˆBˆBå”˜œÑ'Ô'ˆBð Œ{˜BœJÐ&Ð&r   c                 ó*   — t          | j        ¦  «        S r   )ÚstrÚ_linenor   s    r   rO   z/_SourceFileBackedLocatorMixin.get_disambiguatorª   s   € Ý�4”<Ñ Ô Ð r   c                 ó®   — t           j                             |¦  «        sd S  | ||¦  «        }	 |                     ¦   «          n# t          $ r Y d S w xY w|S r   )rD   rI   ÚexistsrJ   ÚOSError©rR   rS   rT   r   s       r   rU   z+_SourceFileBackedLocatorMixin.from_function­   sq   € åŒw�~Š~˜gÑ&Ô&ð 	àˆFØˆs�7˜GÑ$Ô$ˆð	Ø×"Ò"Ñ$Ô$Ð$Ð$øÝð 	ð 	ð 	àˆFˆFð	øøøð ˆó   ¯A Á
AÁAN)r/   r0   r1   re   rM   rO   rf   rU   r   r   r   rh   rh   ›   sW   € € € € € ðð ð
'ð 'ð 'ð!ð !ð !ð ð
ð 
ñ „[ð
ð 
ð 
r   rh   c                   ó>   ‡ — e Zd ZdZd„ Zd„ Zeˆ fd„¦   «         Zˆ xZS )Ú_UserProvidedCacheLocatorzd
    A locator that always point to the user provided directory in
    `numba.config.CACHE_DIR`
    c                 ó¾   — || _         |j        j        | _        |                      |¦  «        }t
          j                             t          j	        |¦  «        | _
        d S r   )rp   Ú__code__Úco_firstlinenorv   rd   rD   rI   r`   r   Ú	CACHE_DIRÚ_cache_path)r   rS   rT   Úcache_subpaths       r   Ú__init__z"_UserProvidedCacheLocator.__init__À   sJ   € ØˆŒØÔ'Ô6ˆŒØ×7Ò7¸Ñ@Ô@ˆÝœ7Ÿ<š<­Ô(8¸-ÑHÔHˆÔÐÐr   c                 ó   — | j         S r   ©r‚   r   s    r   rC   z(_UserProvidedCacheLocator.get_cache_pathÆ   ó   € ØÔÐr   c                 óv   •— t           j        sd S t          t          | ¦  «        }|                     ||¦  «        S r   )r   r�   Úsuperr}   rU   )rR   rS   rT   ÚparentÚ	__class__s       €r   rU   z'_UserProvidedCacheLocator.from_functionÉ   s9   ø€ åÔð 	ØˆFÝÕ0°#Ñ6Ô6ˆØ×#Ò# G¨WÑ5Ô5Ð5r   )	r/   r0   r1   re   r„   rC   rf   rU   Ú__classcell__©r‹   s   @r   r}   r}   »   so   ø€ € € € € ðð ðIð Ið Ið ð  ð  ð ð6ð 6ð 6ð 6ñ „[ð6ð 6ð 6ð 6ð 6r   r}   c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú_InTreeCacheLocatorzn
    A locator for functions backed by a regular Python module with a
    writable __pycache__ directory.
    c                 óÄ   — || _         |j        j        | _        t          j                             t          j                             | j         ¦  «        d¦  «        | _        d S )NÚ__pycache__)	rp   r   r€   rv   rD   rI   r`   rZ   r‚   )r   rS   rT   s      r   r„   z_InTreeCacheLocator.__init__×   sD   € ØˆŒØÔ'Ô6ˆŒÝœ7Ÿ<š<­¬¯ª¸¼Ñ(FÔ(FÈÑVÔVˆÔÐÐr   c                 ó   — | j         S r   r†   r   s    r   rC   z"_InTreeCacheLocator.get_cache_pathÜ   r‡   r   N)r/   r0   r1   re   r„   rC   r   r   r   r�   r�   Ñ   s?   € € € € € ðð ð
Wð Wð Wð
 ð  ð  ð  ð  r   r�   c                   ó4   — e Zd ZdZd„ Zd„ Zed„ ¦   «         ZdS )Ú_UserWideCacheLocatorzˆ
    A locator for functions backed by a regular Python module or a
    frozen executable, cached into a user-wide cache directory.
    c                 óÚ   — || _         |j        j        | _        t	          dd¬¦  «        }|j        }|                      |¦  «        }t          j         	                    ||¦  «        | _
        d S )NÚnumbaF)ÚappnameÚ	appauthor)rp   r   r€   rv   r   Úuser_cache_dirrd   rD   rI   r`   r‚   )r   rS   rT   ÚappdirsÚ	cache_dirrƒ   s         r   r„   z_UserWideCacheLocator.__init__æ   sa   € ØˆŒØÔ'Ô6ˆŒÝ '°UÐ;Ñ;Ô;ˆØÔ*ˆ	Ø×7Ò7¸Ñ@Ô@ˆÝœ7Ÿ<š<¨	°=ÑAÔAˆÔÐÐr   c                 ó   — | j         S r   r†   r   s    r   rC   z$_UserWideCacheLocator.get_cache_pathî   r‡   r   c                 óÚ   — t           j                             |¦  «        st          t          dd¦  «        sd S  | ||¦  «        }	 |                     ¦   «          n# t          $ r Y d S w xY w|S rj   )rD   rI   rx   rl   rm   rJ   ry   rz   s       r   rU   z#_UserWideCacheLocator.from_functionñ   s†   € å”—’˜wÑ'Ô'ð 	­7µ3¸À%Ñ+HÔ+Hð 	ð ˆFØˆs�7˜GÑ$Ô$ˆð	Ø×"Ò"Ñ$Ô$Ð$Ð$øÝð 	ð 	ð 	àˆFˆFð	øøøð ˆs   ÁA Á
A(Á'A(N)r/   r0   r1   re   r„   rC   rf   rU   r   r   r   r”   r”   à   sZ   € € € € € ðð ð
Bð Bð Bð ð  ð  ð ðð ñ „[ðð ð r   r”   c                   ó@   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Z	dS )Ú_IPythonCacheLocatorzT
    A locator for functions entered at the IPython prompt (notebook or other).
    c                 ó¬   — || _         t          j        |¦  «        }t          |t          ¦  «        r	|| _        d S |                     d¦  «        | _        d S )Nzutf-8)rp   ÚinspectÚ	getsourceÚ
isinstanceÚbytesÚ_bytes_sourcer^   )r   rS   rT   Úsources       r   r„   z_IPythonCacheLocator.__init__  sU   € ØˆŒõ Ô" 7Ñ+Ô+ˆÝ�f�eÑ$Ô$ð 	8Ø!'ˆDÔÐÐà!'§¢¨wÑ!7Ô!7ˆDÔÐÐr   c                 óŽ   — 	 ddl m} n# t          $ r	 ddlm} Y nw xY wt          j                              |¦   «         d¦  «        S )Nr   )Úget_ipython_cache_dirÚnumba_cache)ÚIPython.pathsr¨   ÚImportErrorÚIPython.utils.pathrD   rI   r`   )r   r¨   s     r   rC   z#_IPythonCacheLocator.get_cache_path  sv   € ð
	AØ;Ð;Ð;Ð;Ð;Ð;Ð;øÝð 	Að 	Að 	Aà@Ð@Ð@Ð@Ð@Ð@Ð@Ð@ð	Aøøøõ Œw�|Š|Ð1Ð1Ñ3Ô3°]ÑCÔCÐCs   ‚	 ‰›c                 óX   — t          j        | j        ¦  «                             ¦   «         S r   )r\   Úsha256r¥   r_   r   s    r   rM   z%_IPythonCacheLocator.get_source_stamp  s!   € ÝŒ~˜dÔ0Ñ1Ô1×;Ò;Ñ=Ô=Ð=r   c                 óÈ   — d                      | j                             d¦  «        d d…         ¦  «        }t          j        |¦  «                             ¦   «         d d…         S )Nr   Té   é
   )r`   r¥   Ú
splitlinesr\   r®   r_   )r   Ú
firstliness     r   rO   z&_IPythonCacheLocator.get_disambiguator  sT   € ð —X’X˜dÔ0×;Ò;¸DÑAÔAÀ"À1À"ÔEÑFÔFˆ
ÝŒ~˜jÑ)Ô)×3Ò3Ñ5Ô5°c°r°cÔ:Ð:r   c                 ó8  — |                      d¦  «        sQt          j                             t          j                             |¦  «        ¦  «                              d¦  «        sd S  | ||¦  «        }	 |                     ¦   «          n# t          $ r Y d S w xY w|S )Nz	<ipython-Ú
ipykernel_)Ú
startswithrD   rI   ÚbasenamerZ   rJ   ry   rz   s       r   rU   z"_IPythonCacheLocator.from_function'  s©   € ð ×Ò˜{Ñ+Ô+ð	åŒw×Ò¥¤§¢°Ñ 8Ô 8Ñ9Ô9×DÒDÀ\ÑRÔRð	ð ˆFØˆs�7˜GÑ$Ô$ˆð	Ø×"Ò"Ñ$Ô$Ð$Ð$øÝð 	ð 	ð 	àˆFˆFð	øøøð ˆs   Á4B	 Â	
BÂBN)
r/   r0   r1   re   r„   rC   rM   rO   rf   rU   r   r   r   rŸ   rŸ      sx   € € € € € ðð ð8ð 8ð 8ð
Dð 
Dð 
Dð>ð >ð >ð;ð ;ð ;ð ðð ñ „[ðð ð r   rŸ   c                   ó˜   — e Zd ZdZeeeegZd„ Z	d„ Z
ed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd	S )
Ú	CacheImplzÃ
    Provides the core machinery for caching.
    - implement how to serialize and deserialize the data in the cache.
    - control the filename of the cache.
    - provide the cache locator
    c                 ó,  — |j         j        | _        	 |j        }n# t          $ r
 |j        }Y nw xY wt          j        |¦  «        }| j        D ]}| 	                    ||¦  «        }|� nŒt          d|›d|›�¦  «        ‚|| _        t          j        |¦  «        }t          j                             t          j                             |¦  «        ¦  «        d         }|›d|›�}t!          t"          dd¦  «        }	|                      ||	¦  «        | _        d S )Nzcannot cache function z : no locator available for file r   ú.ÚabiflagsÚ )r   r€   rv   r1   ÚAttributeErrorr/   r¡   ÚgetfileÚ_locator_classesrU   ÚRuntimeErrorÚ_locatorrD   rI   Úsplitextr·   rl   rm   Úget_filename_baseÚ_filename_base)
r   rS   ÚqualnameÚsource_pathrR   ÚlocatorÚfilenameÚmodnameÚfullnamer¼   s
             r   r„   zCacheImpl.__init__C  s:  € ØÔ'Ô6ˆŒð	(ØÔ+ˆHˆHøÝð 	(ð 	(ð 	(ØÔ'ˆHˆHˆHð	(øøøõ ”o gÑ.Ô.ˆØÔ(ð 	Hð 	HˆCØ×'Ò'¨°Ñ=Ô=ˆGØÐ"Ø�ð #õ �,Ø08°°¸+¸+ð Gñ Hô Hð HàˆŒõ ”? 7Ñ+Ô+ˆÝ”'×"Ò"¥2¤7×#3Ò#3°HÑ#=Ô#=Ñ>Ô>¸qÔAˆØ%˜g˜g x xÐ0ˆÝ�3 
¨BÑ/Ô/ˆØ"×4Ò4°X¸xÑHÔHˆÔÐÐs   “ ›/®/c                 óÜ   — |                      dd¦  «                              dd¦  «        }d}||| j                             ¦   «         t          j        d         t          j        d         |fz  S )Nú<r½   ú>z%s-%s.py%d%d%sr   é   )ÚreplacerÈ   rO   rm   Úversion_info)r   rË   r¼   Úfixed_fullnameÚfmts        r   rÄ   zCacheImpl.get_filename_base\  sl   € ð "×)Ò)¨#¨rÑ2Ô2×:Ò:¸3ÀÑCÔCˆØˆØ�n d¤l×&DÒ&DÑ&FÔ&FÝÔ& qÔ)­3Ô+;¸AÔ+>ÀðJñ Jð 	Jr   c                 ó   — | j         S r   )rÅ   r   s    r   Úfilename_basezCacheImpl.filename_based  s   € àÔ"Ð"r   c                 ó   — | j         S r   )rÂ   r   s    r   rÈ   zCacheImpl.locatorh  s
   € àŒ}Ðr   c                 ó   — dS )z$Returns the serialized form the dataNr   ©r   r'   s     r   ÚreducezCacheImpl.reducel  ó	   € ð 	ˆr   c                 ó   — dS )z4Returns the de-serialized form of the *reduced_data*Nr   )r   r#   Úreduced_datas      r   ÚrebuildzCacheImpl.rebuildq  rÚ   r   c                 ó   — dS )zEReturns True if the given data is cachable; otherwise, returns False.Nr   rØ   s     r   Úcheck_cachablezCacheImpl.check_cachablev  rÚ   r   N)r/   r0   r1   re   r}   r�   r”   rŸ   rÀ   r„   rÄ   r=   rÕ   rÈ   r   rÙ   rÝ   rß   r   r   r   r¹   r¹   7  sß   € € € € € ðð ð 2Ø+Ø-Ø,ð.Ðð
Ið Ið Ið2Jð Jð Jð ð#ð #ñ „Xð#ð ðð ñ „Xðð ðð ñ „^ðð ðð ñ „^ðð ðð ñ „^ðð ð r   r¹   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚCompileResultCacheImplz>
    Implements the logic to cache CompileResult objects.
    c                 ó*   — |                      ¦   «         S )z4
        Returns a serialized CompileResult
        )Ú_reduce)r   r9   s     r   rÙ   zCompileResultCacheImpl.reduce�  s   € ð �|Š|‰~Œ~Ðr   c                 ó0   — t          j        j        |g|¢R Ž S )z8
        Returns the unserialized CompileResult
        )r   r
   Ú_rebuild©r   r#   Úpayloads      r   rÝ   zCompileResultCacheImpl.rebuild‡  s    € õ Ô%Ô.¨~ÐHÀÐHÐHÐHÐHr   c                 ó  — d}t          d„ |j        D ¦   «         ¦  «        rd}n|j        j        rd}|rXd|j        j                             d¦  «        d         ›d|›�}t          j        |t          | j
        j        | j        ¦  «         d	S d
S )z@
        Check cachability of the given compile result.
        Nc              3   ó&   K  — | ]}|j          V — Œd S r   )Ú	can_cache©Ú.0Úxs     r   ú	<genexpr>z8CompileResultCacheImpl.check_cachable.<locals>.<genexpr>’  s&   è è € Ð4Ð4 1�1”;ˆÐ4Ð4Ð4Ð4Ð4Ð4r   zas it uses lifted codezLas it uses dynamic globals (such as ctypes pointers and large global arrays)z Cannot cache compiled function "r»   rW   z" FT)ÚanyÚliftedÚlibraryÚhas_dynamic_globalsÚfndescrÆ   r[   ÚwarningsÚwarn_explicitr   rÂ   rp   rv   )r   r9   Úcannot_cacher   s       r   rß   z%CompileResultCacheImpl.check_cachable�  s´   € ð ˆÝÐ4Ð4¨¬Ð4Ñ4Ô4Ñ4Ô4ð 	QØ3ˆLˆLØŒ\Ô-ð 	QðPˆLàð 	ð 	à”kÔ*×0Ò0°Ñ5Ô5°bÔ9Ð9Ð9¸<¸<ðIˆCåÔ" 3­Ø#'¤=Ô#9¸4¼<ñIô Ið Ià�5Øˆtr   N)r/   r0   r1   re   rÙ   rÝ   rß   r   r   r   rá   rá   |  sN   € € € € € ðð ðð ð ðIð Ið Iðð ð ð ð r   rá   c                   ó8   ‡ — e Zd ZdZdZd„ Zd„ Zd„ Zˆ fd„Zˆ xZ	S )ÚCodeLibraryCacheImplz<
    Implements the logic to cache CodeLibrary objects.
    Nc                 ó*   — |                      ¦   «         S )z2
        Returns a serialized CodeLibrary
        )Úserialize_using_object_code©r   Úcodelibs     r   rÙ   zCodeLibraryCacheImpl.reduce§  s   € ð ×2Ò2Ñ4Ô4Ð4r   c                 óP   — |                      ¦   «                              |¦  «        S )z6
        Returns the unserialized CodeLibrary
        )ÚcodegenÚunserialize_libraryræ   s      r   rÝ   zCodeLibraryCacheImpl.rebuild­  s$   € ð ×%Ò%Ñ'Ô'×;Ò;¸GÑDÔDÐDr   c                 ó   — |j          S )z=
        Check cachability of the given CodeLibrary.
        )rò   rû   s     r   rß   z#CodeLibraryCacheImpl.check_cachable³  s   € ð Ô.Ð.Ð.r   c                 ó’   •— t          t          | ¦  «        }|                     ||¦  «        }d                     | j        |g¦  «        S )Nú-)r‰   rø   rÄ   r`   Ú_filename_prefix)r   rË   r¼   rŠ   Úresr‹   s        €r   rÄ   z&CodeLibraryCacheImpl.get_filename_base¹  sB   ø€ ÝÕ+¨TÑ2Ô2ˆØ×&Ò& x°Ñ:Ô:ˆØ�xŠx˜Ô.°Ð4Ñ5Ô5Ð5r   )
r/   r0   r1   re   r  rÙ   rÝ   rß   rÄ   rŒ   r�   s   @r   rø   rø      sz   ø€ € € € € ðð ð Ðð5ð 5ð 5ðEð Eð Eð/ð /ð /ð6ð 6ð 6ð 6ð 6ð 6ð 6ð 6ð 6r   rø   c                   ót   — 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ej        d„ ¦   «         ZdS )ÚIndexDataCacheFilezP
    Implements the logic for the index file and data file used by a cache.
    c                 óÊ   — || _         |›d�| _        t          j                             | j         | j        ¦  «        | _        |›d�| _        || _        t          j	        | _
        d S )Nz.nbiz.{number:d}.nbc)r‚   Ú_index_namerD   rI   r`   Ú_index_pathÚ_data_name_patternÚ_source_stampr–   Ú__version__Ú_version)r   r   rÕ   Úsource_stamps       r   r„   zIndexDataCacheFile.__init__Ã  s\   € Ø%ˆÔØ'4 } }Ð6ˆÔÝœ7Ÿ<š<¨Ô(8¸$Ô:JÑKÔKˆÔØ9F¸¸Ð"HˆÔØ)ˆÔÝÔ)ˆŒˆˆr   c                 ó0   — |                       i ¦  «         d S r   )Ú_save_indexr   s    r   r.   zIndexDataCacheFile.flushË  s   € Ø×Ò˜ÑÔÐÐÐr   c                 óh  — |                       ¦   «         }	 ||         }n}# t          $ rp t          |                     ¦   «         ¦  «        }t	          j        d¦  «        D ]}|                      |¦  «        }||vr nŒ|||<   |                      |¦  «         Y nw xY w|                      ||¦  «         dS )z?
        Save a new cache entry with *key* and *data*.
        rÏ   N)	Ú_load_indexÚKeyErrorÚsetÚvaluesÚ	itertoolsÚcountÚ
_data_namer  Ú
_save_data)r   Úkeyr'   Ú	overloadsÚ	data_nameÚexistingÚis          r   ÚsavezIndexDataCacheFile.saveÎ  s×   € ð ×$Ò$Ñ&Ô&ˆ	ð	(à! #œˆIˆIøÝð 	(ð 	(ð 	(å˜9×+Ò+Ñ-Ô-Ñ.Ô.ˆHÝ”_ QÑ'Ô'ð ð �Ø ŸOšO¨AÑ.Ô.�	Ø HÐ,Ð,Ø�Eð -à&ˆI�c‰NØ×Ò˜YÑ'Ô'Ð'Ð'Ð'ð	(øøøð 	�Š˜	 4Ñ(Ô(Ð(Ð(Ð(s   – ŸA7BÂBc                 óª   — |                       ¦   «         }|                     |¦  «        }|€dS 	 |                      |¦  «        S # t          $ r Y dS w xY w)z0
        Load a cache entry with *key*.
        N)r  ÚgetÚ
_load_datary   )r   r  r  r  s       r   ÚloadzIndexDataCacheFile.loadá  sj   € ð ×$Ò$Ñ&Ô&ˆ	Ø—M’M #Ñ&Ô&ˆ	ØÐØˆFð	Ø—?’? 9Ñ-Ô-Ð-øÝð 	ð 	ð 	àˆFˆFð	øøør{   c                 ód  — 	 t          | j        d¦  «        5 }t          j        |¦  «        }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   n# t
          $ r i cY S w xY w|| j        k    ri S t          j        |¦  «        \  }}t          d| j        ¦  «         || j	        k    ri S |S )z|
        Load the cache index and return it as a dictionary (possibly
        empty if cache is empty or obsolete).
        ÚrbNz[cache] index loaded from %r)
Úopenr	  Úpickler#  ÚreadÚFileNotFoundErrorr  Úloadsr   r  )r   ÚfÚversionr'   Ústampr  s         r   r  zIndexDataCacheFile._load_indexï  s  € ð
	Ý�dÔ&¨Ñ-Ô-ð  °Ý œ+ a™.œ.�Ø—v’v‘x”x�ð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  øøõ !ð 	ð 	ð 	àˆIˆIˆIð	øøøð �d”mÒ#Ð#ð ˆIÝ!œ<¨Ñ-Ô-ÑˆˆyÝÐ1°4Ô3CÑDÔDÐDØ�DÔ&Ò&Ð&ð ˆIàÐs4   ‚A —)AÁ A ÁAÁA ÁAÁA ÁA'Á&A'c                 ó2  — | j         |f}|                      |¦  «        }|                      | j        ¦  «        5 }t	          j        | j        |d¬¦  «         |                     |¦  «         d d d ¦  «         n# 1 swxY w Y   t          d| j        ¦  «         d S )NrW   )Úprotocolz[cache] index saved to %r)	r  Ú_dumpÚ_open_for_writer	  r'  Údumpr  Úwriter   )r   r  r'   r+  s       r   r  zIndexDataCacheFile._save_index  sÍ   € ØÔ! 9Ð,ˆØ�zŠz˜$ÑÔˆØ×!Ò! $Ô"2Ñ3Ô3ð 	°qÝŒK˜œ q°2Ð6Ñ6Ô6Ð6Ø�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ 	Ð.°Ô0@ÑAÔAÐAÐAÐAs   ¹2A7Á7A;Á>A;c                 óð   — |                       |¦  «        }t          |d¦  «        5 }|                     ¦   «         }d d d ¦  «         n# 1 swxY w Y   t          j        |¦  «        }t          d|¦  «         |S )Nr%  z[cache] data loaded from %r)Ú
_data_pathr&  r(  r'  r*  r   )r   ÚnamerI   r+  r'   Útups         r   r"  zIndexDataCacheFile._load_data  s§   € Ø�Š˜tÑ$Ô$ˆÝ�$˜ÑÔð 	 Ø—6’6‘8”8ˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	åŒl˜4Ñ Ô ˆÝÐ0°$Ñ7Ô7Ð7Øˆ
s   ¦AÁAÁAc                 óþ   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        5 }|                     |¦  «         d d d ¦  «         n# 1 swxY w Y   t	          d|¦  «         d S )Nz[cache] data saved to %r)r0  r5  r1  r3  r   )r   r6  r'   rI   r+  s        r   r  zIndexDataCacheFile._save_data  s°   € Ø�zŠz˜$ÑÔˆØ�Š˜tÑ$Ô$ˆØ×!Ò! $Ñ'Ô'ð 	¨1Ø�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	åÐ-¨tÑ4Ô4Ð4Ð4Ð4s   Á A"Á"A&Á)A&c                 ó8   — | j                              |¬¦  «        S )N)Únumber)r
  Úformat)r   r:  s     r   r  zIndexDataCacheFile._data_name  s   € ØÔ&×-Ò-°VÐ-Ñ<Ô<Ð<r   c                 óL   — t           j                             | j        |¦  «        S r   )rD   rI   r`   r‚   )r   r6  s     r   r5  zIndexDataCacheFile._data_path"  s   € ÝŒw�|Š|˜DÔ,¨dÑ3Ô3Ð3r   c                 ó    — t          |¦  «        S r   r   )r   Úobjs     r   r0  zIndexDataCacheFile._dump%  s   € Ý�S‰zŒzÐr   c              #   óF  K  — t          j        ¦   «         j        dd…         }|›d|›�}	 t          |d¦  «        5 }|V — ddd¦  «         n# 1 swxY w Y   t	          j        ||¦  «         dS # t          $ r( 	 t	          j        |¦  «         n# t          $ r Y nw xY w‚ w xY w)z¦
        Open *filepath* for writing in a race condition-free way (hopefully).
        uuid4 is used to try and avoid name collisions on a shared filesystem.
        Né   z.tmp.Úwb)	ÚuuidÚuuid4Úhexr&  rD   rÐ   Ú	ExceptionÚunlinkry   )r   ÚfilepathÚuidÚtmpnamer+  s        r   r1  z"IndexDataCacheFile._open_for_write(  s  è è € õ Œj‰lŒlÔ˜s ˜sÔ#ˆØ!)  ¨3¨3Ð/ˆð
	Ý�g˜tÑ$Ô$ð ¨Ø���ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð åŒJ�w Ñ)Ô)Ð)Ð)Ð)øÝð 	ð 	ð 	ðÝ”	˜'Ñ"Ô"Ð"Ð"øÝð ð ð Ø�ðøøøàð	øøøsR   «A. »AÁ A. ÁAÁA. ÁAÁA. Á.
B Á9BÂB Â
BÂB ÂBÂB N)r/   r0   r1   re   r„   r.   r  r#  r  r  r"  r  r  r5  r0  Ú
contextlibÚcontextmanagerr1  r   r   r   r  r  ¿  så   € € € € € ðð ð*ð *ð *ðð ð ð)ð )ð )ð&ð ð ðð ð ð2Bð Bð Bðð ð ð5ð 5ð 5ð=ð =ð =ð4ð 4ð 4ðð ð ð Ôðð ñ Ôðð ð r   r  c                   óˆ   — e Zd ZdZdZd„ Zd„ Zed„ ¦   «         Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zej        d„ ¦   «         Zd„ ZdS )ÚCachea<  
    A per-function compilation cache.  The cache saves data in separate
    data files and maintains information in an index file.

    There is one index file per function and Python version
    ("function_name-<lineno>.pyXY.nbi") which contains a mapping of
    signatures and architectures to data files.
    It is prefixed by a versioning key and a timestamp of the Python source
    file containing the function.

    There is one data file ("function_name-<lineno>.pyXY.<number>.nbc")
    per function, function signature, target architecture and Python version.

    Separate index and data files per Python version avoid pickle
    compatibility problems.

    Note:
    This contains the driver logic only.  The core logic is provided
    by a subclass of ``CacheImpl`` specified as *_impl_class* in the subclass.
    Nc                 ój  — t          |¦  «        | _        || _        |                      |¦  «        | _        | j        j                             ¦   «         | _        | j        j                             ¦   «         }| j        j	        }t          | j        ||¬¦  «        | _        |                      ¦   «          d S )N)r   rÕ   r  )ÚreprÚ_nameÚ_py_funcÚ_impl_classÚ_implrÈ   rC   r‚   rM   rÕ   r  Ú_cache_filer*   )r   rS   r  rÕ   s       r   r„   zCache.__init__V  sœ   € Ý˜'‘]”]ˆŒ
ØˆŒØ×%Ò% gÑ.Ô.ˆŒ
Øœ:Ô-×<Ò<Ñ>Ô>ˆÔà”zÔ)×:Ò:Ñ<Ô<ˆØœ
Ô0ˆÝ-¸Ô9IØ<IØ;GðIñ Iô IˆÔð 	�Š‰Œˆˆˆr   c                 ó2   — d| j         j        ›d| j        ›d�S )NrÍ   z	 py_func=rÎ   )r‹   r/   rP  r   s    r   Ú__repr__zCache.__repr__c  s    € € Ø$(¤NÔ$;Ð$;Ð$;¸T¼Z¸Z¸ZÐHÐHr   c                 ó   — | j         S r   r†   r   s    r   r   zCache.cache_pathf  s   € àÔÐr   c                 ó   — d| _         d S )NT©Ú_enabledr   s    r   r*   zCache.enablej  s   € ØˆŒˆˆr   c                 ó   — d| _         d S )NFrY  r   s    r   r,   zCache.disablem  s   € ØˆŒˆˆr   c                 ó8   — | j                              ¦   «          d S r   )rT  r.   r   s    r   r.   zCache.flushp  s   € ØÔ×ÒÑ Ô Ð Ð Ð r   c                 ó²   — |                      ¦   «          |                      ¦   «         5  |                      ||¦  «        cddd¦  «         S # 1 swxY w Y   dS )zr
        Load and recreate the cached object for the given signature,
        using the *target_context*.
        N)ÚrefreshÚ!_guard_against_spurious_io_errorsÚ_load_overloadr!   s      r   r$   zCache.load_overloads  sŸ   € ð 	×ÒÑ Ô Ð Ø×3Ò3Ñ5Ô5ð 	<ð 	<Ø×&Ò& s¨NÑ;Ô;ð	<ð 	<ð 	<ð 	<ñ 	<ô 	<ð 	<ð 	<ð 	<ð 	<ð 	<ð 	<øøøð 	<ð 	<ð 	<ð 	<ð 	<ð 	<s   ©AÁAÁAc                 óÖ   — | j         sd S |                      ||                     ¦   «         ¦  «        }| j                             |¦  «        }|�| j                             ||¦  «        }|S r   )rZ  Ú
_index_keyrþ   rT  r#  rS  rÝ   )r   r"   r#   r  r'   s        r   r`  zCache._load_overload~  sh   € ØŒ}ð 	ØˆFØ�oŠo˜c >×#9Ò#9Ñ#;Ô#;Ñ<Ô<ˆØÔ×$Ò$ SÑ)Ô)ˆØÐØ”:×%Ò% n°dÑ;Ô;ˆDØˆr   c                 óŒ   — |                       ¦   «         5  |                      ||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zE
        Save the data for the given signature in the cache.
        N)r_  Ú_save_overloadr&   s      r   r(   zCache.save_overload‡  s�   € ð ×3Ò3Ñ5Ô5ð 	+ð 	+Ø×Ò  TÑ*Ô*Ð*ð	+ð 	+ð 	+ñ 	+ô 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+øøøð 	+ð 	+ð 	+ð 	+ð 	+ð 	+s   •9¹=Á =c                 ó,  — | j         sd S | j                             |¦  «        sd S | j        j                             ¦   «          |                      ||j        ¦  «        }| j                             |¦  «        }| j         	                    ||¦  «         d S r   )
rZ  rS  rß   rÈ   rJ   rb  rþ   rÙ   rT  r  )r   r"   r'   r  s       r   rd  zCache._save_overloadŽ  sŽ   € ØŒ}ð 	ØˆFØŒz×(Ò(¨Ñ.Ô.ð 	ØˆFØŒ
Ô×,Ò,Ñ.Ô.Ð.Ø�oŠo˜c 4¤<Ñ0Ô0ˆØŒz× Ò  Ñ&Ô&ˆØÔ×Ò˜c 4Ñ(Ô(Ð(Ð(Ð(r   c              #   óœ   K  — t           j        dk    r5	 d V — d S # t          $ r!}|j        t          j        k    r‚ Y d }~d S d }~ww xY wd V — d S )NÚnt)rD   r6  ry   ÚerrnoÚEACCES)r   Úes     r   r_  z'Cache._guard_against_spurious_io_errors˜  sw   è è € åŒ7�dŠ?ˆ?ðØ�����øÝð ð ð Ø”7�eœlÒ*Ð*Øð +Ð*Ð*Ð*Ð*Ð*øøøøðøøøð
 ˆEˆEˆEˆEˆEs   ” š
A¤A Á Ac                 ó  — | j         j        j        }| j         j        �3t	          d„ | j         j        D ¦   «         ¦  «        }t          |¦  «        }nd}d„ }||                     ¦   «          ||¦  «         ||¦  «        ffS )a
  
        Compute index key for the given signature and codegen.
        It includes a description of the OS, target architecture and hashes of
        the bytecode for the function and, if the function has a __closure__,
        a hash of the cell_contents.
        Nc                 ó   — g | ]	}|j         ‘Œ
S r   )Úcell_contentsrë   s     r   ú
<listcomp>z$Cache._index_key.<locals>.<listcomp>¯  s   € ÐNÐNÐN¨q˜1œ?ÐNÐNÐNr   r   c                 óN   — t          j        | ¦  «                             ¦   «         S r   )r\   r®   r_   )rí   s    r   ú<lambda>z"Cache._index_key.<locals>.<lambda>¶  s   € �7œ>¨!Ñ,Ô,×6Ò6Ñ8Ô8€ r   )rQ  r   Úco_codeÚ__closure__Útupler   Úmagic_tuple)r   r"   rþ   Ú	codebytesÚcvarsÚ	cvarbytesÚhashers          r   rb  zCache._index_key¦  s•   € ð ”MÔ*Ô2ˆ	ØŒ=Ô$Ð0ÝÐNÐN°D´MÔ4MÐNÑNÔNÑOÔOˆEõ ˜e™œˆIˆIàˆIà8Ð8ˆØ�W×(Ò(Ñ*Ô*¨V¨V°IÑ->Ô->Ø-3¨V°IÑ->Ô->ð-Að Bð 	Br   )r/   r0   r1   re   rR  r„   rV  r=   r   r*   r,   r.   r$   r`  r(   rd  rJ  rK  r_  rb  r   r   r   rM  rM  =  sý   € € € € € ðð ð, €Kðð ð ðIð Ið Ið ð ð  ñ „Xð ðð ð ðð ð ð!ð !ð !ð<ð <ð <ðð ð ð+ð +ð +ð)ð )ð )ð Ôðð ñ ÔððBð Bð Bð Bð Br   rM  c                   ó   — e Zd ZdZeZdS )ÚFunctionCachezF
    Implements Cache that saves and loads CompileResult objects.
    N)r/   r0   r1   re   rá   rR  r   r   r   rz  rz  »  s   € € € € € ðð ð )€K€K€Kr   rz  r½   c                 ó¨   ‡ ‡— ‰ t           vsJ ‚t                                ‰ ¦  «          G ˆ fd„dt          ¦  «        Š G ˆfd„dt          ¦  «        }|S )zØ
    Create a Cache class for additional compilation features to cache their
    result for reuse.  The cache is saved in filename pattern like
    in ``FunctionCache`` but with additional *prefix* as specified.
    c                   ó   •— e Zd Z” ZdS )ú6make_library_cache.<locals>.CustomCodeLibraryCacheImplN)r/   r0   r1   r  )Úprefixs   €r   ÚCustomCodeLibraryCacheImplr}  Ð  s   ø€ € € € € Ø!ÐÐÐr   r  c                   ó   •— e Zd ZdZ” ZdS )ú(make_library_cache.<locals>.LibraryCachez�
        Implements Cache that saves and loads CodeLibrary objects for additional
        feature for the specified python function.
        N)r/   r0   r1   re   rR  )r  s   €r   ÚLibraryCacher�  Ó  s    ø€ € € € € ð	ð 	ð 1ˆˆˆr   r‚  )Ú_lib_cache_prefixesÚaddrø   rM  )r~  r‚  r  s   ` @r   Úmake_library_cacher…  Æ  s�   øø€ ð Õ,Ð,Ð,Ð,Ð,Ý×Ò˜FÑ#Ô#Ð#ð"ð "ð "ð "ð "ð "ð "Õ%9ñ "ô "ð "ð1ð 1ð 1ð 1ð 1ð 1ð 1•uñ 1ô 1ð 1ð Ðr   )3re   Úabcr   r   r   rJ  rh  r\   r¡   r  rD   r'  rm   rF   rB  rô   Únumba.misc.appdirsr   r–   Únumba.core.errorsr   Únumba.core.baser   Únumba.core.codegenr	   Únumba.core.compilerr
   Ú
numba.corer   r   Únumba.core.serializer   r   r   r4   r?   Úobjectrh   r}   r�   r”   rŸ   r¹   rá   rø   r  rM  rz  r  rƒ  r…  r   r   r   ú<module>r�     sí  ððð ð
 :Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø Ð Ð Ð Ø 	€	€	€	Ø €€€Ø 
€
€
€
Ø €€€Ø €€€Ø €€€à &Ð &Ð &Ð &Ð &Ð &à €€€Ø *Ð *Ð *Ð *Ð *Ð *Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø *Ð *Ð *Ð *Ð *Ð *Ø -Ð -Ð -Ð -Ð -Ð -Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø &Ð &Ð &Ð &Ð &Ð &ðð ð ð&ð &ð &ð &ð &�wð &ñ &ô &ð &ðRð ð ð ð �ñ ô ð ð*6-ð 6-ð 6-ð 6-ð 6-˜gð 6-ñ 6-ô 6-ð 6-ðrð ð ð ð  Fñ ô ð ð@6ð 6ð 6ð 6ð 6Ð =¸}ñ 6ô 6ð 6ð, ð  ð  ð  ð  Ð7¸ñ  ô  ð  ðð ð ð ð Ð9¸=ñ ô ð ð@4ð 4ð 4ð 4ð 4˜=ñ 4ô 4ð 4ðnBð Bð Bð Bð B˜'ð Bñ Bô Bð BðJ!ð !ð !ð !ð !˜Yñ !ô !ð !ðH6ð 6ð 6ð 6ð 6˜9ñ 6ô 6ð 6ð>{ð {ð {ð {ð {˜ñ {ô {ð {ð|{Bð {Bð {Bð {Bð {BˆFñ {Bô {Bð {Bð|)ð )ð )ð )ð )�Eñ )ô )ð )ð �c˜2˜$‘i”iÐ ðð ð ð ð r   