
    qh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- Z6y).z+
Caching mechanism for compiled functions.
    )ABCMetaabstractmethodabstractpropertyN)AppDirs)Path)NumbaWarning)BaseContext)CodeLibrary)CompileResult)configcompilerdumpsc                 F    t         j                  r| |z  } t        |        y y N)r   DEBUG_CACHEprint)msgargss     L/var/www/html/engine/venv/lib/python3.12/site-packages/numba/core/caching.py
_cache_logr       s     Djc
     c                   l    e Zd Zed        Zed        Zed        Zed        Zed        Z	ed        Z
y)_Cachec                      y)zW
        The base filesystem path of this cache (for example its root folder).
        N selfs    r   
cache_pathz_Cache.cache_path(       r   c                      y)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                      y)z<
        Save the overload for the given signature.
        Nr   r   r#   datas      r   save_overloadz_Cache.save_overload6   r    r   c                      y)z#
        Enable the cache.
        Nr   r   s    r   enablez_Cache.enable<   r    r   c                      y)z$
        Disable the cache.
        Nr   r   s    r   disablez_Cache.disableB   r    r   c                      y)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   &   sx     
    
  
  
  r   r   )	metaclassc                   :    e Zd Zed        Zd Zd Zd Zd Zd Z	y)	NullCachec                      y r   r   r   s    r   r   zNullCache.cache_pathP   s    r   c                      y r   r   r"   s      r   r%   zNullCache.load_overloadT       r   c                      y r   r   )r   r#   cress      r   r)   zNullCache.save_overloadW   r8   r   c                      y r   r   r   s    r   r+   zNullCache.enableZ   r8   r   c                      y r   r   r   s    r   r-   zNullCache.disable]   r8   r   c                      y 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   s-     r   r5   c                   f    e Zd ZdZd Zed        Zed        Zed        Ze	d        Z
e	d        Zy)	_CacheLocatorz<
    A filesystem locator for caching a given function.
    c                     | j                         }t        j                  |d       t        j                  |      j                          y )NT)exist_ok)dir)get_cache_pathosmakedirstempfileTemporaryFileclose)r   paths     r   ensure_cache_pathz_CacheLocator.ensure_cache_pathi   s5    ""$
D4(4(..0r   c                      y)zA
        Return the directory the function is cached in.
        Nr   r   s    r   rD   z_CacheLocator.get_cache_patho   r    r   c                      y)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                      y)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                 J   t         j                  j                  |      }t         j                  j                  |      }t         j                  j	                  |      d   }t        j                  |j                               j                         }dj                  ||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   ss     www'''//$'GGMM'*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   sp    1  
     " " - -r   r@   c                   ,    e Zd ZdZd Zd Zed        Zy)_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   sG    3%((B'B {{BJJ&&r   c                 ,    t        | j                        S r   )str_linenor   s    r   rP   z/_SourceFileBackedLocatorMixin.get_disambiguator   s    4<<  r   c                     t         j                  j                  |      sy  | ||      }	 |j                          |S # t        $ r Y y w xY wr   )rE   rJ   existsrK   OSErrorrT   rU   rV   r   s       r   rW   z+_SourceFileBackedLocatorMixin.from_function   sM    ww~~g&7G$	""$   		s   = 	A	A	N)r0   r1   r2   rg   rN   rP   rh   rW   r   r   r   rj   rj      s%    
'! 
 
r   rj   c                   8     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                  | _        | j	                  |      }t
        j                  j                  t        j                  |      | _
        y r   )rr   __code__co_firstlinenory   rf   rE   rJ   rb   r   	CACHE_DIR_cache_path)r   rU   rV   cache_subpaths       r   __init__z"_UserProvidedCacheLocator.__init__   sI    ''6677@77<<(8(8-Hr   c                     | j                   S r   r   r   s    r   rD   z(_UserProvidedCacheLocator.get_cache_path       r   c                 j    t         j                  sy t        t        |       }|j	                  ||      S r   )r   r   superr   rW   )rT   rU   rV   parent	__class__s       r   rW   z'_UserProvidedCacheLocator.from_function   s/    0#6##GW55r   )	r0   r1   r2   rg   r   rD   rh   rW   __classcell__r   s   @r   r   r      s'    I  6 6r   r   c                       e Zd ZdZd Zd Zy)_InTreeCacheLocatorzn
    A locator for functions backed by a regular Python module with a
    writable __pycache__ directory.
    c                     || _         |j                  j                  | _        t        j
                  j                  t        j
                  j                  | j                         d      | _        y )N__pycache__)	rr   r   r   ry   rE   rJ   rb   r\   r   )r   rU   rV   s      r   r   z_InTreeCacheLocator.__init__   sD    ''6677<<(F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
 r   r   c                   ,    e Zd ZdZd Zd Zed        Zy)_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
                  }| j                  |      }t        j                  j                  ||      | _
        y 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__   sZ    ''66'U;**	77@77<<	=Ar   c                     | j                   S r   r   r   s    r   rD   z$_UserWideCacheLocator.get_cache_path   r   r   c                     t         j                  j                  |      st        t        dd      sy  | ||      }	 |j                          |S # t        $ r Y y w xY wrl   )rE   rJ   r{   rn   ro   rK   r|   r}   s       r   rW   z#_UserWideCacheLocator.from_function   sZ    w'73%+H 7G$	""$   		s   A 	AAN)r0   r1   r2   rg   r   rD   rh   rW   r   r   r   r   r      s&    
B   r   r   c                   8    e Zd ZdZd Zd Zd Zd Zed        Z	y)_IPythonCacheLocatorzT
    A locator for functions entered at the IPython prompt (notebook or other).
    c                     || _         t        j                  |      }t        |t              r|| _        y |j                  d      | _        y )Nzutf-8)rr   inspect	getsource
isinstancebytes_bytes_sourcer`   )r   rU   rV   sources       r   r   z_IPythonCacheLocator.__init__  s>     ""7+fe$!'D!'w!7Dr   c                     	 ddl m} t        j
                  j                   |       d      S # t        $ r	 ddlm} Y 6w xY w)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  s<    
	A; ww||13]CC  	A@	As   - ??c                 \    t        j                  | j                        j                         S r   )r^   sha256r   ra   r   s    r   rN   z%_IPythonCacheLocator.get_source_stamp  s     ~~d001;;==r   c                     dj                  | j                  j                  d      d d       }t        j                  |      j                         d d S )Nr   T   
   )rb   r   
splitlinesr^   r   ra   )r   
firstliness     r   rP   z&_IPythonCacheLocator.get_disambiguator   sI     XXd00;;DA"1EF
~~j)335cr::r   c                    |j                  d      sLt        j                  j                  t        j                  j	                  |            j                  d      sy  | ||      }	 |j                          |S # t        $ r Y y w xY w)Nz	<ipython-
ipykernel_)
startswithrE   rJ   basenamer\   rK   r|   r}   s       r   rW   z"_IPythonCacheLocator.from_function)  sw     {+ww 89DD\R7G$	""$   		s   (A: :	BBN)
r0   r1   r2   rg   r   rD   rN   rP   rh   rW   r   r   r   r   r     s0    8
D>;  r   r   c                   B    e Zd ZdZd Zed        Zd Zd Ze	d        Z
y)_ZipCacheLocatorzP
    A locator for functions backed by Python modules within a zip archive.
    c                 "   || _         |j                  j                  | _        | j	                  |      \  | _        | _        t        dd      }|j                  }| j                  |      }t        j                  j                  ||      | _        y 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__>  sv    ''66.2.B.B7.K++ 'U;**	77@77<<	=Ar   c           	         t        |       }t        |j                        D ]^  \  }}|j                  d      st	        t        |j                  d |dz           }t	        t        |j                  |dz   d         }||fc S  t        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$tTZZ!a%%89: #D$**QUW*=$> ?..		/
 4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'    WWT^^${{BJJ&&r   c                     d|vry  | ||      S )Nr   r   rS   s      r   rW   z_ZipCacheLocator.from_function[  s     7G$$r   N)r0   r1   r2   rg   r   staticmethodr   rD   rN   rh   rW   r   r   r   r   r   9  s?    
B 6 6 ' % %r   r   c                   z    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y	)
	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                 8   |j                   j                  | _        	 |j                  }t        j                  |      }| j                  D ]  }|j                  ||      }| n t        d|d|      || _        t        j                  |      }t        j                  j                  t        j                  j                  |            d   }|d|}t!        t"        dd      }	| j%                  ||	      | _        y # t        $ r |j
                  }Y w xY w)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6	(++H oog.(( 	HC''=G"	H
 08+ G H H ??7+''""277#3#3H#=>qA%x03
B/"44XxH%  	(''H	(s   D DDc                     |j                  dd      j                  dd      }d}||| j                  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  sk     "))#r2::3Cndll&D&D&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                      y)z$Returns the serialized form the dataNr   r   r(   s     r   reducezCacheImpl.reduce       	r   c                      y)z4Returns the de-serialized form of the *reduced_data*Nr   )r   r$   reduced_datas      r   rebuildzCacheImpl.rebuild  r   r   c                      y)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2J # #        r   r   c                   "    e Zd ZdZd Zd Zd Zy)CompileResultCacheImplz>
    Implements the logic to cache CompileResult objects.
    c                 "    |j                         S )z4
        Returns a serialized CompileResult
        )_reduce)r   r:   s     r   r   zCompileResultCacheImpl.reduce  s     ||~r   c                 B    t        j                  j                  |g| S )z8
        Returns the unserialized CompileResult
        )r   r   _rebuildr   r$   payloads      r   r   zCompileResultCacheImpl.rebuild  s      %%..~HHHr   c                 L   d}t        d |j                  D              rd}n|j                  j                  rd}|rid|j                  j
                  j                  d      d   d|}t        j                  |t        | j                  j                  | j                         y	y
)z@
        Check cachability of the given compile result.
        Nc              3   6   K   | ]  }|j                      y wr   )	can_cache).0xs     r   	<genexpr>z8CompileResultCacheImpl.check_cachable.<locals>.<genexpr>  s     411;;4s   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3L\\--PLkk**005b9<IC""3#'==#9#94<<Ir   N)r0   r1   r2   rg   r   r   r   r   r   r   r   r     s    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                 "    |j                         S )z2
        Returns a serialized CodeLibrary
        )serialize_using_object_coder   codelibs     r   r   zCodeLibraryCacheImpl.reduce  s     2244r   c                 @    |j                         j                  |      S )z6
        Returns the unserialized CodeLibrary
        )codegenunserialize_libraryr   s      r   r   zCodeLibraryCacheImpl.rebuild  s     %%';;G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        |       }|j                  ||      }dj                  | j                  |g      S )N-)r   r  r   rb   _filename_prefix)r   r   r   r   resr   s        r   r   z&CodeLibraryCacheImpl.get_filename_base  s<    +T2&&x:xx..455r   )
r0   r1   r2   rg   r  r   r   r   r   r   r   s   @r   r  r    s*     5E/6 6r   r  c                   v    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y)IndexDataCacheFilezP
    Implements the logic for the index file and data file used by a cache.
    c                     || _         |d| _        t        j                  j	                  | j                   | j                        | _        |d| _        || _        t        j                  | _
        y )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__  sX    %'4677<<(8(8$:J:JK9F"H)))r   c                 &    | j                  i        y r   )_save_indexr   s    r   r/   zIndexDataCacheFile.flush  s    r   c                 2   | j                         }	 ||   }| j                  ||       y# t        $ rc t        |j                               }t	        j
                  d      D ]  }| j                  |      }||vs n ||<   | j                  |       Y ~w xY w)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     $$&		(!#I 		4(  	(9++-.H__Q'  OOA.	H, 'IcNY'	(s   * AB:BBc                     | j                         }|j                  |      }|y	 | j                  |      S # t        $ r Y yw xY w)z0
        Load a cache entry with *key*.
        N)r)  get
_load_datar|   )r   r1  r2  r3  s       r   loadzIndexDataCacheFile.load  sO     $$&	MM#&		??9-- 		s   7 	AAc                 j   	 t        | j                  d      5 }t        j                  |      }|j	                         }ddd       | j                  k7  ri S t        j                        \  }}t        d| j                         || j                  k7  ri S |S # 1 sw Y   [xY w# t
        $ r i cY S w xY w)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   pickler9  readFileNotFoundErrorr$  loadsr   r"  )r   fversionr(   stampr2  s         r   r)  zIndexDataCacheFile._load_index  s    
	d&&-   ++a.vvx  dmm# I!<<-y143C3CDD&&& I#    ! 	I	s'   B$ &BB$ B!B$ $B21B2c                 4   | j                   |f}| j                  |      }| j                  | j                        5 }t	        j
                  | j                  |d       |j                  |       d d d        t        d| j                         y # 1 sw Y    xY w)NrY   )protocolz[cache] index saved to %r)	r"  _dump_open_for_writer   r=  dumpr$  writer   )r   r2  r(   rA  s       r   r'  zIndexDataCacheFile._save_index6  s}    !!9,zz$!!$"2"23 	qKKq26GGDM	 	.0@0@A	 	s   4BBc                     | j                  |      }t        |d      5 }|j                         }d d d        t        j                        }t        d|       |S # 1 sw Y   ,xY w)Nr;  z[cache] data loaded from %r)
_data_pathr<  r>  r=  r@  r   )r   namerJ   rA  r(   tups         r   r8  zIndexDataCacheFile._load_data>  sZ    t$$ 	668D	ll4 0$7
		 	s   AA#c                     | j                  |      }| j                  |      }| j                  |      5 }|j                  |       d d d        t	        d|       y # 1 sw Y   xY w)Nz[cache] data saved to %r)rF  rK  rG  rI  r   )r   rL  r(   rJ   rA  s        r   r0  zIndexDataCacheFile._save_dataF  sY    zz$t$!!$' 	1GGDM	-t4	 	s   AA$c                 :    | j                   j                  |      S )N)number)r!  format)r   rP  s     r   r/  zIndexDataCacheFile._data_nameM  s    &&--V-<<r   c                 V    t         j                  j                  | j                  |      S r   )rE   rJ   rb   r   )r   rL  s     r   rK  zIndexDataCacheFile._data_pathP  s    ww||D,,d33r   c                     t        |      S r   r   )r   objs     r   rF  zIndexDataCacheFile._dumpS  s    Szr   c              #   :  K   t        j                         j                  dd }|d|}	 t        |d      5 }| ddd       t	        j
                  ||       y# 1 sw Y    xY w# t        $ r' 	 t	        j                  |        # t        $ r Y  w xY ww xY w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tmpnamerA  s        r   rG  z"IndexDataCacheFile._open_for_writeV  s      jjls#!)3/
	gt$ JJw)   			'"   		sV   )BA( AA( BA%!A( (	B2BB	BBBBBN)r0   r1   r2   rg   r   r/   r5  r9  r)  r'  r8  r0  r/  rK  rF  
contextlibcontextmanagerrG  r   r   r   r  r    sY    *)&2B5=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y)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                 ~   t        |      | _        || _        | j                  |      | _        | j                  j
                  j                         | _        | j                  j
                  j                         }| j                  j                  }t        | j                  ||      | _        | j                          y )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.
::--<<>zz))::<

00-9I9I<I;GI 	r   c                 P    d| j                   j                  d| j                  dS )Nr   z	 py_func=r   )r   r0   rf  r   s    r   __repr__zCache.__repr__  s    $(NN$;$;TZZHHr   c                     | j                   S r   r   r   s    r   r   zCache.cache_path  s    r   c                     d| _         y )NT_enabledr   s    r   r+   zCache.enable  s	    r   c                     d| _         y )NFro  r   s    r   r-   zCache.disable  s	    r   c                 8    | j                   j                          y r   )rj  r/   r   s    r   r/   zCache.flush  s     r   c                     |j                          | j                         5  | j                  ||      cddd       S # 1 sw Y   yxY w)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  sA     	 335 	<&&sN;	< 	< 	<s	   =Ac                     | j                   sy | j                  ||j                               }| j                  j	                  |      }|| j
                  j                  ||      }|S r   )rp  
_index_keyr  rj  r9  ri  r   )r   r#   r$   r1  r(   s        r   rv  zCache._load_overload  s\    }}ooc>#9#9#;<$$S)::%%nd;Dr   c                 r    | j                         5  | j                  ||       ddd       y# 1 sw Y   yxY w)zE
        Save the data for the given signature in the cache.
        N)ru  _save_overloadr'   s      r   r)   zCache.save_overload  s5     335 	+T*	+ 	+ 	+s   -6c                 D   | j                   sy | j                  j                  |      sy | j                  j                  j	                          | j                  ||j                        }| j                  j                  |      }| j                  j                  ||       y r   )
rp  ri  r   r   rK   rx  r  r   rj  r5  )r   r#   r(   r1  s       r   rz  zCache._save_overload  su    }}zz((.

,,.ooc4<<0zz  &c4(r   c              #      K   t         j                  dk(  r	 d  y d  y # t        $ r(}|j                  t        j                  k7  r Y d }~y d }~ww xY ww)Nnt)rE   rL  r|   errnoEACCES)r   es     r   ru  z'Cache._guard_against_spurious_io_errors  sG     77d?   77ell* +s*   A! A	AAAAAc                 J   | j                   j                  j                  }| j                   j                  Ct	        | j                   j                  D cg c]  }|j
                   c}      }t        |      }nd}d }||j                          ||       ||      ffS c c}w )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.
        r   c                 H    t        j                  |       j                         S r   )r^   r   ra   )r  s    r   <lambda>z"Cache._index_key.<locals>.<lambda>  s    7>>!,668 r   )rg  r   co_code__closure__tuplecell_contentsr   magic_tuple)r   r#   r  	codebytesr  cvars	cvarbyteshashers           r   rx  zCache._index_key  s     MM**22	==$$0DMM4M4MNq1??NOE eII8W((*VI->-3I->-A B 	B Os   B )r0   r1   r2   rg   rh  r   rl  r>   r   r+   r-   r/   r%   rv  r)   rz  r`  ra  ru  rx  r   r   r   rc  rc  k  sp    , KI    !<+)  Br   rc  c                       e Zd ZdZeZy)FunctionCachezF
    Implements Cache that saves and loads CompileResult objects.
    N)r0   r1   r2   rg   r   rh  r   r   r   r  r    s     )Kr   r  r   c                       t         vsJ t         j                           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W  Zy)6make_library_cache.<locals>.CustomCodeLibraryCacheImplN)r0   r1   r2   r  )prefixs   r   CustomCodeLibraryCacheImplr    s	    !r   r  c                       e Zd ZdZW  Zy)(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   rh  )r  s   r   LibraryCacher    s    	 1r   r  )_lib_cache_prefixesaddr  rc  )r  r  r  s   ` @r   make_library_cacher    sC     ,,,,F#"%9 "1u 1 r   )7rg   abcr   r   r   r`  r~  r^   r   r-  rE   r=  ro   rG   rX  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  rc  r  r+  r  r  r   r   r   <module>r     s;  
 : 9      	  
    &    * ' * - ' &&w &R *6-g 6-rF @6 =} 6, 7  9= @4= 4n&%4m &%PF' FR!Y !H69 6>{ {|{BF {B|)E ) 2$i r   