
    J/Phb                        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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(e&          Z- G d  d!e          Z. G d" d#e.          Z/ G d$ d%e.          Z0 G d& d'e'          Z1 G d( d)e$          Z2 G d* d+e2          Z3 e4d,g          Z5d- Z6dS ).z+
Caching mechanism for compiled functions.
    )ABCMetaabstractmethodabstractpropertyN)AppDirs)Path)NumbaWarning)BaseContext)CodeLibrary)CompileResult)configcompilerdumpsc                 J    t           j        r| |z  } t          |            d S d S N)r   DEBUG_CACHEprint)msgargss     R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/core/caching.py
_cache_logr       s/     Dj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_overload6   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.disableB   r    r   c                     dS )z"
        Flush the cache.
        Nr   r   s    r   flushz_Cache.flushH   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_pathP   s    tr   c                     d S r   r   r"   s      r   r%   zNullCache.load_overloadT       r   c                     d S r   r   )r   r#   cress      r   r)   zNullCache.save_overloadW   r8   r   c                     d S r   r   r   s    r   r+   zNullCache.enableZ   r8   r   c                     d S r   r   r   s    r   r-   zNullCache.disable]   r8   r   c                     d S r   r   r   s    r   r/   zNullCache.flush`   r8   r   N)
r0   r1   r2   propertyr   r%   r)   r+   r-   r/   r   r   r   r5   r5   O   sx          X            r   r5   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_pathi   sN    ""$$
D4((((4(((..00000r   c                     dS )zA
        Return the directory the function is cached in.
        Nr   r   s    r   rD   z_CacheLocator.get_cache_patho   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_stampu   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_disambiguator|   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 )zGiven 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).
        _)
rE   rJ   abspathdirnamesplithashlibsha1encode	hexdigestjoin)rT   rV   rJ   subpath	parentdirhasheds         r   get_suitable_cache_subpathz(_CacheLocator.get_suitable_cache_subpath   s     ww'''//$''GMM'**2.	 gnn..//99;;xxF+,,,r   N)r0   r1   r2   __doc__rK   r   rD   rN   rP   classmethodrW   rf   r   r   r   r@   r@   d   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sysrE   stat
executable_py_filest_mtimest_sizer   sts     r   rN   z._SourceFileBackedLocatorMixin.get_source_stamp   sK    3%(( 	(((BB''B {BJ&&r   c                 *    t          | j                  S r   )str_linenor   s    r   rP   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   )rE   rJ   existsrK   OSErrorrT   rU   rV   r   s       r   rW   z+_SourceFileBackedLocatorMixin.from_function   sq    w~~g&& 	Fs7G$$	""$$$$ 	 	 	FF	    A 
AAN)r0   r1   r2   rg   rN   rP   rh   rW   r   r   r   rj   rj      sW         
' ' '! ! ! 
 
 [
 
 
r   rj   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   )rr   __code__co_firstlinenory   rf   rE   rJ   rb   r   	CACHE_DIR_cache_path)r   rU   rV   cache_subpaths       r   __init__z"_UserProvidedCacheLocator.__init__   sJ    '677@@7<<(8-HHr   c                     | j         S r   r   r   s    r   rD   z(_UserProvidedCacheLocator.get_cache_path       r   c                 v    t           j        sd S t          t          |           }|                    ||          S r   )r   r   superr   rW   )rT   rU   rV   parent	__class__s       r   rW   z'_UserProvidedCacheLocator.from_function   s9     	F0#66##GW555r   )	r0   r1   r2   rg   r   rD   rh   rW   __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__)	rr   r   r   ry   rE   rJ   rb   r\   r   )r   rU   rV   s      r   r   z_InTreeCacheLocator.__init__   sD    '67<<(F(FVVr   c                     | j         S r   r   r   s    r   rD   z"_InTreeCacheLocator.get_cache_path   r   r   N)r0   r1   r2   rg   r   rD   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)rr   r   r   ry   r   user_cache_dirrf   rE   rJ   rb   r   r   rU   rV   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   rD   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 rl   )rE   rJ   r{   rn   ro   rK   r|   r}   s       r   rW   z#_UserWideCacheLocator.from_function   s    w'' 	73%+H+H 	 Fs7G$$	""$$$$ 	 	 	FF	 s   A 
A('A(N)r0   r1   r2   rg   r   rD   rh   rW   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)rr   inspect	getsource
isinstancebytes_bytes_sourcer`   )r   rU   rV   sources       r   r   z_IPythonCacheLocator.__init__  sU     "7++fe$$ 	8!'D!'w!7!7D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.pathrE   rJ   rb   )r   r   s     r   rD   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   ra   r   s    r   rN   z%_IPythonCacheLocator.get_source_stamp  s!    ~d011;;===r   c                     d                     | j                            d          d d                   }t          j        |                                          d d         S )Nr   T   
   )rb   r   
splitlinesr^   r   ra   )r   
firstliness     r   rP   z&_IPythonCacheLocator.get_disambiguator   sT     XXd0;;DAA"1"EFF
~j))3355crc::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_)
startswithrE   rJ   basenamer\   rK   r|   r}   s       r   rW   z"_IPythonCacheLocator.from_function)  s     {++	w 8 899DD\RR	 Fs7G$$	""$$$$ 	 	 	FF	 s   4B	 	
BBN)
r0   r1   r2   rg   r   rD   rN   rP   rh   rW   r   r   r   r   r     sx         8 8 8
D 
D 
D> > >; ; ;   [  r   r   c                   P    e Zd ZdZd Zed             Zd Zd Ze	d             Z
dS )_ZipCacheLocatorzP
    A locator for functions backed by Python modules within a zip archive.
    c                    || _         |j        j        | _        |                     |          \  | _        | _        t          dd          }|j        }| 	                    |          }t          j                            ||          | _        d S r   )rr   r   r   ry   _split_zip_path	_zip_path_internal_pathr   r   rf   rE   rJ   rb   r   r   s         r   r   z_ZipCacheLocator.__init__>  s    '6.2.B.B7.K.K++ 'U;;;*	77@@7<<	=AAr   c           	      @   t          |           }t          |j                  D ]l\  }}|                    d          rRt	          t          |j        d |dz                       }t	          t          |j        |dz   d                     }||fc S mt          d          )N.zip   zNo zip file found in path)r   	enumeratepartsendswithrx   
ValueError)rV   rJ   ipartzip_pathinternal_paths         r   r   z _ZipCacheLocator._split_zip_pathJ  s    G}} ,, 	/ 	/GAt}}V$$ /tTZ!a%%89:: #D$*QUWW*=$> ? ?..../ 4555r   c                     | j         S r   r   r   s    r   rD   z_ZipCacheLocator.get_cache_pathT  r   r   c                 P    t          j        | j                  }|j        |j        fS r   )rE   rp   r   rs   rt   ru   s     r   rN   z!_ZipCacheLocator.get_source_stampW  s"    WT^$${BJ&&r   c                 &    d|vrd S  | ||          S )Nr   r   rS   s      r   rW   z_ZipCacheLocator.from_function[  s$      4s7G$$$r   N)r0   r1   r2   rg   r   staticmethodr   rD   rN   rh   rW   r   r   r   r   r   9  s         
B 
B 
B 6 6 \6     ' ' ' % % [% % %r   r   c                       e Zd ZdZe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   ry   r2   AttributeErrorr0   r   getfile_locator_classesrW   RuntimeError_locatorrE   rJ   splitextr   rn   ro   get_filename_base_filename_base)
r   rU   qualnamesource_pathrT   locatorfilenamemodnamefullnamer   s
             r   r   zCacheImpl.__init__q  s:   '6	(+HH 	( 	( 	('HHH	( og..( 	H 	HC''==G" # ,08++ G H H H ?7++'""27#3#3H#=#=>>qA%ggxx03
B//"44Xx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   r   )replacer   rP   ro   version_info)r   r   r   fixed_fullnamefmts        r   r   zCacheImpl.get_filename_base  sl     "))#r22::3CCndl&D&D&F&F&q)3+;A+>J J 	Jr   c                     | j         S r   )r   r   s    r   filename_basezCacheImpl.filename_base  s    ""r   c                     | j         S r   )r   r   s    r   r   zCacheImpl.locator  s
    }r   c                     dS )z$Returns the serialized form the dataNr   r   r(   s     r   reducezCacheImpl.reduce  	     	r   c                     dS )z4Returns the de-serialized form of the *reduced_data*Nr   )r   r$   reduced_datas      r   rebuildzCacheImpl.rebuild  r   r   c                     dS )zEReturns True if the given data is cachable; otherwise, returns False.Nr   r   s     r   check_cachablezCacheImpl.check_cachable  r   r   N)r0   r1   r2   rg   r   r   r   r   r   r   r   r   r>   r   r   r   r   r   r   r   r   r   r   r   a  s          	"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   r:   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411;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   rY   z" FT)anyliftedlibraryhas_dynamic_globalsfndescr   r]   warningswarn_explicitr   r   rr   ry   )r   r:   cannot_cacher   s       r   r   z%CompileResultCacheImpl.check_cachable  s     4444444 	Q3LL\- 	QPL 	 	k*0055b999<<IC"3#'=#94<I I I5tr   N)r0   r1   r2   rg   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   rb   _filename_prefix)r   r   r   r   resr   s        r   r   z&CodeLibraryCacheImpl.get_filename_base  sB    +T22&&x::xx.4555r   )
r0   r1   r2   rg   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_namerE   rJ   rb   _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existingr   s          r   savezIndexDataCacheFile.save  s     $$&&		(!#II 	( 	( 	(9++--..H_Q''   OOA..	H,,E -&IcN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_datar|   )r   r3  r4  r5  s       r   loadzIndexDataCacheFile.load  sj     $$&&	MM#&&	F	??9--- 	 	 	FF	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(   stampr4  s         r   r+  zIndexDataCacheFile._load_index  s   
	d&--   +a..vvxx                              ! 	 	 	III	 dm## I!<--y143C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 )NrY   )protocolz[cache] index saved to %r)	r$  _dump_open_for_writer"  r?  dumpr&  writer   )r   r4  r(   rC  s       r   r)  zIndexDataCacheFile._save_index6  s    !9,zz$!!$"233 	qKq26666GGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	.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?  rB  r   )r   namerJ   rC  r(   tups         r   r:  zIndexDataCacheFile._load_data>  s    t$$$ 	6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	l4  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)rH  rM  rI  rK  r   )r   rN  r(   rJ   rC  s        r   r2  zIndexDataCacheFile._save_dataF  s    zz$t$$!!$'' 	1GGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	-t44444s    A""A&)A&c                 8    | j                             |          S )N)number)r#  format)r   rR  s     r   r1  zIndexDataCacheFile._data_nameM  s    &--V-<<<r   c                 L    t           j                            | j        |          S r   )rE   rJ   rb   r   )r   rN  s     r   rM  zIndexDataCacheFile._data_pathP  s    w||D,d333r   c                      t          |          S r   r   )r   objs     r   rH  zIndexDataCacheFile._dumpS  s    Szz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>  rE   r   	Exceptionunlinkr|   )r   filepathuidtmpnamerC  s        r   rI  z"IndexDataCacheFile._open_for_writeV  s      jllss#!)33/
	gt$$               Jw))))) 	 	 		'""""   	sR   A. A A. AA. AA. .
B 9BB 
BB BB N)r0   r1   r2   rg   r   r/   r7  r;  r+  r)  r:  r2  r1  rM  rH  
contextlibcontextmanagerrI  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   rD   r   rN   r   r  _cache_filer+   )r   rU   r'  r   s       r   r   zCache.__init__  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   r0   rh  r   s    r   __repr__zCache.__repr__  s      $(N$;$;$;TZZZHHr   c                     | j         S r   r   r   s    r   r   zCache.cache_path  s    r   c                     d| _         d S )NT_enabledr   s    r   r+   zCache.enable  s    r   c                     d| _         d S )NFrq  r   s    r   r-   zCache.disable  s    r   c                 8    | j                                          d S r   )rl  r/   r   s    r   r/   zCache.flush  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_overload  s     	   3355 	< 	<&&sN;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   AAAc                     | j         sd S |                     ||                                          }| j                            |          }|| j                            ||          }|S r   )rr  
_index_keyr  rl  r;  rk  r   )r   r#   r$   r3  r(   s        r   rx  zCache._load_overload  sh    } 	Fooc>#9#9#;#;<<$$S)):%%nd;;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)rw  _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   )
rr  rk  r   r   rK   rz  r  r   rl  r7  )r   r#   r(   r3  s       r   r|  zCache._save_overload  s    } 	Fz((.. 	F
,,...ooc4<00z  &&c4(((((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)rE   rN  r|   errnoEACCES)r   es     r   rw  z'Cache._guard_against_spurious_io_errors  sw      7d??   7el** +*****
 EEEEEs    
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Nq1?NNNr   r   c                 N    t          j        |                                           S r   )r^   r   ra   )r  s    r   <lambda>z"Cache._index_key.<locals>.<lambda>  s    7>!,,6688 r   )ri  r   co_code__closure__tupler   magic_tuple)r   r#   r  	codebytescvars	cvarbyteshashers          r   rz  zCache._index_key  s     M*2	=$0NNDM4MNNNOOE eIII88W((**VVI->->-3VI->->-A B 	Br   )r0   r1   r2   rg   rj  r   rn  r>   r   r+   r-   r/   r%   rx  r)   r|  rb  rc  rw  rz  r   r   r   re  re  k  s         , K  I I I     X     ! ! !< < <  + + +) ) )   B B B B Br   re  c                       e Zd ZdZeZdS )FunctionCachezF
    Implements Cache that saves and loads CompileResult objects.
    N)r0   r1   r2   rg   r   rj  r   r   r   r  r    s          )KKKr   r  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)r0   r1   r2   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)r0   r1   r2   rg   rj  )r  s   r   LibraryCacher    s         	 	 1r   r  )_lib_cache_prefixesaddr  re  )r  r  r  s   ` @r   make_library_cacher    s     ,,,,,F###" " " " " " "%9 " " "1 1 1 1 1 1 1u 1 1 1 r   )7rg   abcr   r   r   rb  r  r^   r   r/  rE   r?  ro   rG   rZ  r  numba.misc.appdirsr   zipfilepathlibr   r   numba.core.errorsr   numba.core.baser	   numba.core.codegenr
   numba.core.compilerr   
numba.corer   r   numba.core.serializer   r   r   r5   r@   objectrj   r   r   r   r   r   r   r   r  r  re  r  r-  r  r  r   r   r   <module>r     s6   
 : 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&% &% &% &% &%4m &% &% &%PF F F F F' F F F FR! ! ! ! !Y ! ! !H6 6 6 6 69 6 6 6>{ { { { { { { {|{B {B {B {B {BF {B {B {B|) ) ) ) )E ) ) ) c2$ii     r   