
    shb                     L   S r SSKJrJrJr  SSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKrSSKJr  SSKrSSKJr  SSKrSSKJr  SSKJr  SSKJr  SS	KJr  SS
KJrJ r   SSK!J"r"  S r# " S S\S9r$ " S S\$5      r% " S S\S9r& " S S\'5      r( " S S\(\&5      r) " S S\(\&5      r* " S S\(\&5      r+ " S S\&5      r, " S S\(\&5      r- " S  S!\S9r. " S" S#\.5      r/ " S$ S%\.5      r0 " S& S'\'5      r1 " S( S)\$5      r2 " S* S+\25      r3\4" S,/5      r5S- r6g).z+
Caching mechanism for compiled functions.
    )ABCMetaabstractmethodabstractpropertyN)AppDirs)Path)NumbaWarning)BaseContext)CodeLibrary)CompileResult)configcompilerdumpsc                 N    [         R                  (       a  X-  n [        U 5        g g N)r   DEBUG_CACHEprint)msgargss     f/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/caching.py
_cache_logr       s    jc
     c                   t    \ rS rSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rSrg	)
_Cache&   c                     g)zG
The base filesystem path of this cache (for example its root folder).
N selfs    r   
cache_path_Cache.cache_path(       r   c                     g)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_overload_Cache.load_overload.   r"   r   c                     g)z,
Save the overload for the given signature.
Nr   r   r%   datas      r   save_overload_Cache.save_overload6   r"   r   c                     g)z
Enable the cache.
Nr   r   s    r   enable_Cache.enable<   r"   r   c                     g)z
Disable the cache.
Nr   r   s    r   disable_Cache.disableB   r"   r   c                     g)z
Flush the cache.
Nr   r   s    r   flush_Cache.flushH   r"   r   r   N)__name__
__module____qualname____firstlineno__r   r    r   r'   r,   r/   r2   r5   __static_attributes__r   r   r   r   r   &   sx     
    
  
  
  r   r   )	metaclassc                   B    \ rS rSr\S 5       rS rS rS rS r	S r
Srg	)
	NullCacheO   c                     g r   r   r   s    r   r    NullCache.cache_pathP   s    r   c                     g r   r   r$   s      r   r'   NullCache.load_overloadT       r   c                     g r   r   )r   r%   cress      r   r,   NullCache.save_overloadW   rD   r   c                     g r   r   r   s    r   r/   NullCache.enableZ   rD   r   c                     g r   r   r   s    r   r2   NullCache.disable]   rD   r   c                     g r   r   r   s    r   r5   NullCache.flush`   rD   r   r   N)r7   r8   r9   r:   propertyr    r'   r,   r/   r2   r5   r;   r   r   r   r>   r>   O   s-     r   r>   c                   n    \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	\
S 5       r\
S 5       rS	rg
)_CacheLocatord   z4
A filesystem locator for caching a given function.
c                     U R                  5       n[        R                  " USS9  [        R                  " US9R                  5         g )NT)exist_ok)dir)get_cache_pathosmakedirstempfileTemporaryFileclose)r   paths     r   ensure_cache_path_CacheLocator.ensure_cache_pathi   s5    ""$
D4(4(..0r   c                     g)z1
Return the directory the function is cached in.
Nr   r   s    r   rU   _CacheLocator.get_cache_patho   r"   r   c                     g)zc
Get a timestamp representing the source code's freshness.
Can return any picklable Python object.
Nr   r   s    r   get_source_stamp_CacheLocator.get_source_stampu   r"   r   c                     g)z
Get a string disambiguator for this locator's function.
It should allow disambiguating different but similarly-named functions.
Nr   r   s    r   get_disambiguator_CacheLocator.get_disambiguator|   r"   r   c                     [         e)zM
Create a locator instance for the given function located in the
given file.
)NotImplementedErrorclspy_funcpy_files      r   from_function_CacheLocator.from_function   s
     "!r   c                 J   [         R                  R                  U5      n[         R                  R                  U5      n[         R                  R	                  U5      S   n[
        R                  " UR                  5       5      R                  5       nSR                  XE/5      $ )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).
_)
rV   r[   abspathdirnamesplithashlibsha1encode	hexdigestjoin)ri   rk   r[   subpath	parentdirhasheds         r   get_suitable_cache_subpath(_CacheLocator.get_suitable_cache_subpath   sq     www'''//$'GGMM'*2.	 gnn./99;xx+,,r   r   N)r7   r8   r9   r:   __doc__r\   r   rU   ra   rd   classmethodrl   r|   r;   r   r   r   rP   rP   d   sp    1  
     " " - -r   rP   c                   4    \ rS rSrSrS rS r\S 5       rSr	g)_SourceFileBackedLocatorMixin   zZ
A cache locator mixin for functions which are backed by a well-known
Python source file.
c                     [        [        SS5      (       a%  [        R                  " [        R                  5      nO [        R                  " U R
                  5      nUR                  UR                  4$ NfrozenF)getattrsysrV   stat
executable_py_filest_mtimest_sizer   sts     r   ra   ._SourceFileBackedLocatorMixin.get_source_stamp   sJ    3%(((B'B {{BJJ&&r   c                 ,    [        U R                  5      $ r   )str_linenor   s    r   rd   /_SourceFileBackedLocatorMixin.get_disambiguator   s    4<<  r   c                     [         R                  R                  U5      (       d  g U " X5      n UR                  5         U$ ! [         a     g f = fr   )rV   r[   existsr\   OSErrorri   rj   rk   r   s       r   rl   +_SourceFileBackedLocatorMixin.from_function   sN    ww~~g&&7$	""$   		s   A 
AAr   N)
r7   r8   r9   r:   r~   ra   rd   r   rl   r;   r   r   r   r   r      s%    
'! 
 
r   r   c                   B   ^  \ rS rSrSrS rS r\U 4S j5       rSr	U =r
$ )_UserProvidedCacheLocator   zX
A locator that always point to the user provided directory in
`numba.config.CACHE_DIR`
c                     X l         UR                  R                  U l        U R	                  U5      n[
        R                  R                  [        R                  U5      U l
        g r   )r   __code__co_firstlinenor   r|   rV   r[   rx   r   	CACHE_DIR_cache_path)r   rj   rk   cache_subpaths       r   __init__"_UserProvidedCacheLocator.__init__   sG    ''6677@77<<(8(8-Hr   c                     U R                   $ r   r   r   s    r   rU   (_UserProvidedCacheLocator.get_cache_path       r   c                 r   > [         R                  (       d  g [        [        U 5      nUR	                  X5      $ r   )r   r   superr   rl   )ri   rj   rk   parent	__class__s       r   rl   '_UserProvidedCacheLocator.from_function   s-    0#6##G55r   r   r   r   )r7   r8   r9   r:   r~   r   rU   r   rl   r;   __classcell__r   s   @r   r   r      s'    I  6 6r   r   c                   $    \ rS rSrSrS rS rSrg)_InTreeCacheLocator   zb
A locator for functions backed by a regular Python module with a
writable __pycache__ directory.
c                     X l         UR                  R                  U l        [        R
                  R                  [        R
                  R                  U R                   5      S5      U l        g )N__pycache__)	r   r   r   r   rV   r[   rx   rr   r   )r   rj   rk   s      r   r   _InTreeCacheLocator.__init__   sB    ''6677<<(FVr   c                     U R                   $ r   r   r   s    r   rU   "_InTreeCacheLocator.get_cache_path   r   r   r   N)r7   r8   r9   r:   r~   r   rU   r;   r   r   r   r   r      s    
W
 r   r   c                   4    \ rS rSrSrS rS r\S 5       rSr	g)_UserWideCacheLocator   z|
A locator for functions backed by a regular Python module or a
frozen executable, cached into a user-wide cache directory.
c                     X l         UR                  R                  U l        [	        SSS9nUR
                  nU R                  U5      n[        R                  R                  XE5      U l
        g NnumbaF)appname	appauthor)r   r   r   r   r   user_cache_dirr|   rV   r[   rx   r   r   rj   rk   appdirs	cache_dirr   s         r   r   _UserWideCacheLocator.__init__   sV    ''66'U;**	77@77<<	Ar   c                     U R                   $ r   r   r   s    r   rU   $_UserWideCacheLocator.get_cache_path   r   r   c                     [         R                  R                  U5      (       d  [        [        SS5      (       d  g U " X5      n UR                  5         U$ ! [         a     g f = fr   )rV   r[   r   r   r   r\   r   r   s       r   rl   #_UserWideCacheLocator.from_function   s^    w''73%+H+H 7$	""$   		s   A 
A$#A$r   N)
r7   r8   r9   r:   r~   r   rU   r   rl   r;   r   r   r   r   r      s&    
B   r   r   c                   @    \ rS rSrSrS rS rS rS r\	S 5       r
Srg	)
_IPythonCacheLocatori  zL
A locator for functions entered at the IPython prompt (notebook or other).
c                     X l         [        R                  " U5      n[        U[        5      (       a  X0l        g UR                  S5      U l        g )Nzutf-8)r   inspect	getsource
isinstancebytes_bytes_sourcerv   )r   rj   rk   sources       r   r   _IPythonCacheLocator.__init__  s=     ""7+fe$$!'!'w!7Dr   c                      SSK Jn  [        R
                  R                  U" 5       S5      $ ! [         a	    SSKJn   N7f = f)Nr   )get_ipython_cache_dirnumba_cache)IPython.pathsr   ImportErrorIPython.utils.pathrV   r[   rx   )r   r   s     r   rU   #_IPythonCacheLocator.get_cache_path  s<    
	A; ww||13]CC  	A@	As   - A A c                 ^    [         R                  " U R                  5      R                  5       $ r   )rt   sha256r   rw   r   s    r   ra   %_IPythonCacheLocator.get_source_stamp  s     ~~d001;;==r   c                     SR                  U R                  R                  S5      S S 5      n[        R                  " U5      R                  5       S S $ )Nr   T   
   )rx   r   
splitlinesrt   r   rw   )r   
firstliness     r   rd   &_IPythonCacheLocator.get_disambiguator   sI     XXd00;;DA"1EF
~~j)335cr::r   c                 &   UR                  S5      (       dQ  [        R                  R                  [        R                  R	                  U5      5      R                  S5      (       d  g U " X5      n UR                  5         U$ ! [         a     g f = f)Nz	<ipython-
ipykernel_)
startswithrV   r[   basenamerr   r\   r   r   s       r   rl   "_IPythonCacheLocator.from_function)  s{     {++ww 89DD\RR7$	""$   		s   1B 
BB)r   r   N)r7   r8   r9   r:   r~   r   rU   ra   rd   r   rl   r;   r   r   r   r   r     s0    8
D>;  r   r   c                   J    \ rS rSrSrS r\S 5       rS rS r	\
S 5       rSrg	)
_ZipCacheLocatori9  zH
A locator for functions backed by Python modules within a zip archive.
c                    X l         UR                  R                  U l        U R	                  U5      u  U l        U l        [        SSS9nUR                  nU R                  U5      n[        R                  R                  XE5      U l        g r   )r   r   r   r   _split_zip_path	_zip_path_internal_pathr   r   r|   rV   r[   rx   r   r   s         r   r   _ZipCacheLocator.__init__>  sr    ''66.2.B.B7.K++ 'U;**	77@77<<	Ar   c           	      $   [        U 5      n[        UR                  5       Hb  u  p#UR                  S5      (       d  M  [	        [        UR                  S US-    6 5      n[	        [        UR                  US-   S  6 5      nXE4s  $    [        S5      e)N.zip   zNo zip file found in path)r   	enumeratepartsendswithr   
ValueError)rk   r[   ipartzip_pathinternal_paths         r   r    _ZipCacheLocator._split_zip_pathJ  s    G} ,GA}}V$$tTZZ!a%%89: #D$**QUW*=$> ?..	 -
 455r   c                     U R                   $ r   r   r   s    r   rU   _ZipCacheLocator.get_cache_pathT  r   r   c                 r    [         R                  " U R                  5      nUR                  UR                  4$ r   )rV   r   r   r   r   r   s     r   ra   !_ZipCacheLocator.get_source_stampW  s'    WWT^^${{BJJ&&r   c                      SU;  a  g U " X5      $ )Nr   r   rh   s      r   rl   _ZipCacheLocator.from_function[  s     7$$r   )r   r   r   r   r   N)r7   r8   r9   r:   r~   r   staticmethodr   rU   ra   r   rl   r;   r   r   r   r   r   9  s?    
B 6 6 ' % %r   r   c                       \ rS rSrSr\\\\\	/r
S rS r\S 5       r\S 5       r\S 5       r\S 5       r\S	 5       rS
rg)	CacheImplia  z
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                 F   UR                   R                  U l         UR                  n[        R                  " U5      nU R                   H  nUR                  X5      nUc  M    O   [        SU< SU< 35      eXPl        [        R                  " U5      n[        R                  R                  [        R                  R                  U5      5      S   nU< SU< 3n[!        ["        SS5      n	U R%                  X5      U l        g ! [         a    UR
                  n Nf = f)Nzcannot cache function z : no locator available for file r   .abiflags )r   r   r   r9   AttributeErrorr7   r   getfile_locator_classesrl   RuntimeError_locatorrV   r[   splitextr   r   r   get_filename_base_filename_base)
r   rj   qualnamesource_pathri   locatorfilenamemodnamefullnamer  s
             r   r   CacheImpl.__init__q  s    ''66	(++H oog.((C''=G" )
 08+ G H H ??7+''""277#3#3H#=>qA%x03
B/"44XH%  	(''H	(s   D D D c                     UR                  SS5      R                  SS5      nSnXCU R                  R                  5       [        R                  S   [        R                  S   U4-  $ )N<r  >z%s-%s.py%d%d%sr   r   )replacer  rd   r   version_info)r   r  r  fixed_fullnamefmts        r   r  CacheImpl.get_filename_base  si     "))#r2::3Cdll&D&D&F&&q)3+;+;A+>J J 	Jr   c                     U R                   $ r   )r  r   s    r   filename_baseCacheImpl.filename_base  s    """r   c                     U R                   $ r   )r  r   s    r   r  CacheImpl.locator  s    }}r   c                     g)z$Returns the serialized form the dataNr   r   r+   s     r   reduceCacheImpl.reduce       	r   c                     g)z4Returns the de-serialized form of the *reduced_data*Nr   )r   r&   reduced_datas      r   rebuildCacheImpl.rebuild  r(  r   c                     g)zEReturns True if the given data is cachable; otherwise, returns False.Nr   r%  s     r   check_cachableCacheImpl.check_cachable  r(  r   )r  r   r  N)r7   r8   r9   r:   r~   r   r   r   r   r   r
  r   r  rN   r   r  r   r&  r+  r.  r;   r   r   r   r  r  a  s     	"I2J # #        r   r  c                   *    \ rS rSrSrS rS rS rSrg)CompileResultCacheImpli  z6
Implements the logic to cache CompileResult objects.
c                 "    UR                  5       $ )z$
Returns a serialized CompileResult
)_reduce)r   rF   s     r   r&  CompileResultCacheImpl.reduce  s     ||~r   c                 D    [         R                  R                  " U/UQ76 $ )z(
Returns the unserialized CompileResult
)r   r   _rebuildr   r&   payloads      r   r+  CompileResultCacheImpl.rebuild  s      %%..~HHHr   c                 p   Sn[        S UR                   5       5      (       a  SnOUR                  R                  (       a  SnU(       al  SUR                  R
                  R                  S5      S   < SU< 3n[        R                  " U[        U R                  R                  U R                  5        g	g
)z0
Check cachability of the given compile result.
Nc              3   B   #    U  H  oR                   (       + v   M     g 7fr   )	can_cache).0xs     r   	<genexpr>8CompileResultCacheImpl.check_cachable.<locals>.<genexpr>  s     41;;s   zas it uses lifted codezLas it uses dynamic globals (such as ctypes pointers and large global arrays)z Cannot cache compiled function "r  ro   z" FT)anyliftedlibraryhas_dynamic_globalsfndescr  rs   warningswarn_explicitr   r  r   r   )r   rF   cannot_cacher   s       r   r.  %CompileResultCacheImpl.check_cachable  s     44443L\\--PLkk**005b9<IC""3#'==#9#94<<Ir   r   N)	r7   r8   r9   r:   r~   r&  r+  r.  r;   r   r   r   r1  r1    s    Ir   r1  c                   B   ^  \ rS rSrSrSrS rS rS rU 4S jr	Sr
U =r$ )	CodeLibraryCacheImpli  z4
Implements the logic to cache CodeLibrary objects.
Nc                 "    UR                  5       $ )z"
Returns a serialized CodeLibrary
)serialize_using_object_coder   codelibs     r   r&  CodeLibraryCacheImpl.reduce  s     2244r   c                 @    UR                  5       R                  U5      $ )z&
Returns the unserialized CodeLibrary
)codegenunserialize_libraryr7  s      r   r+  CodeLibraryCacheImpl.rebuild  s     %%';;GDDr   c                 $    UR                   (       + $ )z-
Check cachability of the given CodeLibrary.
)rD  rN  s     r   r.  #CodeLibraryCacheImpl.check_cachable  s     ....r   c                    > [        [        U 5      nUR                  X5      nSR                  U R                  U/5      $ )N-)r   rK  r  rx   _filename_prefix)r   r  r  r   resr   s        r   r  &CodeLibraryCacheImpl.get_filename_base  s:    +T2&&x:xx..455r   r   )r7   r8   r9   r:   r~   rY  r&  r+  r.  r  r;   r   r   s   @r   rK  rK    s*     5E/6 6r   rK  c                   ~    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS r\R"                  S 5       rSrg)IndexDataCacheFilei  zH
Implements the logic for the index file and data file used by a cache.
c                     Xl         U< S3U l        [        R                  R	                  U R                   U R                  5      U l        U< S3U l        X0l        [        R                  U l
        g )Nz.nbiz.{number:d}.nbc)r   _index_namerV   r[   rx   _index_path_data_name_pattern_source_stampr   __version___version)r   r    r   source_stamps       r   r   IndexDataCacheFile.__init__  sT    %'4677<<(8(8$:J:JK9F"H)))r   c                 &    U R                  0 5        g r   )_save_indexr   s    r   r5   IndexDataCacheFile.flush  s    r   c                 6   U R                  5       n X1   nU R                  XB5        g! [         af    [        UR                  5       5      n[        R
                  " S5       H  nU R                  U5      nXE;  d  M    O   WX1'   U R                  U5         Nf = f)z/
Save a new cache entry with *key* and *data*.
r   N)	_load_indexKeyErrorsetvalues	itertoolscount
_data_namerh  
_save_data)r   keyr+   	overloads	data_nameexistingr   s          r   saveIndexDataCacheFile.save  s     $$&		(!I 		(  	(9++-.H__Q' OOA.	, ( 'INY'	(s   ( AB<BBc                     U R                  5       nUR                  U5      nUc  g U R                  U5      $ ! [         a     gf = f)z 
Load a cache entry with *key*.
N)rk  get
_load_datar   )r   rs  rt  ru  s       r   loadIndexDataCacheFile.load  sO     $$&	MM#&		??9-- 		s   8 
AAc                 z    [        U R                  S5       n[        R                  " U5      nUR	                  5       nSSS5        WU R                  :w  a  0 $ [        R                  " W5      u  pE[        SU R                  5        X@R                  :w  a  0 $ U$ ! , (       d  f       Na= f! [
         a    0 s $ f = f)zd
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FileNotFoundErrorrd  loadsr   rb  )r   fversionr+   stamprt  s         r   rk  IndexDataCacheFile._load_index  s    
	d&&- ++a.vvx . dmm# I!<<-143C3CD&&& I# .- ! 	I	s-   B+ 'BB+ 
B($B+ (B+ +B:9B:c                 :   U R                   U4nU R                  U5      nU R                  U R                  5       n[        R
                  " U R                  USS9  UR                  U5        S S S 5        [        SU R                  5        g ! , (       d  f       N%= f)Nro   )protocolz[cache] index saved to %r)	rb  _dump_open_for_writer`  r  dumprd  writer   )r   rt  r+   r  s       r   rh  IndexDataCacheFile._save_index6  sv    !!9,zz$!!$"2"23qKKq26GGDM 4 	.0@0@A 43s   2B
Bc                     U R                  U5      n[        US5       nUR                  5       nS S S 5        [        R                  " W5      n[        SU5        U$ ! , (       d  f       N2= f)Nr  z[cache] data loaded from %r)
_data_pathr  r  r  r  r   )r   namer[   r  r+   tups         r   r{  IndexDataCacheFile._load_data>  sS    t$$668D ll4 0$7
	 s   A
A)c                     U R                  U5      nU R                  U5      nU R                  U5       nUR                  U5        S S S 5        [	        SU5        g ! , (       d  f       N= f)Nz[cache] data saved to %r)r  r  r  r  r   )r   r  r+   r[   r  s        r   rr  IndexDataCacheFile._save_dataF  sR    zz$t$!!$'1GGDM (-t4 ('s   A
A)c                 4    U R                   R                  US9$ )N)number)ra  format)r   r  s     r   rq  IndexDataCacheFile._data_nameM  s    &&--V-<<r   c                 V    [         R                  R                  U R                  U5      $ r   )rV   r[   rx   r   )r   r  s     r   r  IndexDataCacheFile._data_pathP  s    ww||D,,d33r   c                     [        U5      $ r   r   )r   objs     r   r  IndexDataCacheFile._dumpS  s    Szr   c              #   P  #    [         R                  " 5       R                  SS nU< SU< 3n [        US5       nUv   SSS5        [        R
                  " X15        g! , (       d  f       N%= f! [         a)     [        R                  " U5        e ! [         a     e f = ff = f7f)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  rV   r  	Exceptionunlinkr   )r   filepathuidtmpnamer  s        r   r  "IndexDataCacheFile._open_for_writeV  s      jjls#!)3/
	gt$ %JJw) %$  			'"   		sW   ,B&A0 A A0 B&
A-)A0 0
B#;BB#
BB#BB##B&)r   ra  r_  r`  rb  rd  N)r7   r8   r9   r:   r~   r   r5   rw  r|  rk  rh  r{  rr  rq  r  r  
contextlibcontextmanagerr  r;   r   r   r   r]  r]    sY    *)&2B5=4  r   r]  c                       \ rS rSrSrSrS rS r\S 5       r	S r
S rS	 rS
 rS rS rS r\R$                  S 5       rS rSrg)Cacheik  a   
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                 v   [        U5      U l        Xl        U R                  U5      U l        U R                  R
                  R                  5       U l        U R                  R
                  R                  5       nU R                  R                  n[        U R                  UUS9U l        U R                  5         g )N)r    r   re  )repr_name_py_func_impl_class_implr  rU   r   ra   r   r]  _cache_filer/   )r   rj   re  r   s       r   r   Cache.__init__  s    ']
%%g.
::--<<>zz))::<

00-9I9I<I;GI 	r   c                 T    SU R                   R                  < SU R                  < S3$ )Nr  z	 py_func=r  )r   r7   r  r   s    r   __repr__Cache.__repr__  s    $(NN$;$;TZZHHr   c                     U R                   $ r   r   r   s    r   r    Cache.cache_path  s    r   c                     SU l         g )NT_enabledr   s    r   r/   Cache.enable  s	    r   c                     SU l         g )NFr  r   s    r   r2   Cache.disable  s	    r   c                 8    U R                   R                  5         g r   )r  r5   r   s    r   r5   Cache.flush  s     r   c                     UR                  5         U R                  5          U R                  X5      sSSS5        $ ! , (       d  f       g= f)zZ
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'   Cache.load_overload  s6     	 335&&s; 655s	   <
A
c                     U R                   (       d  g U R                  XR                  5       5      nU R                  R	                  U5      nUb  U R
                  R                  X$5      nU$ r   )r  
_index_keyrR  r  r|  r  r+  )r   r%   r&   rs  r+   s        r   r  Cache._load_overload  sX    }}ooc#9#9#;<$$S)::%%n;Dr   c                 z    U R                  5          U R                  X5        SSS5        g! , (       d  f       g= f)z5
Save the data for the given signature in the cache.
N)r  _save_overloadr*   s      r   r,   Cache.save_overload  s*     335* 655s   ,
:c                 T   U R                   (       d  g U R                  R                  U5      (       d  g U R                  R                  R	                  5         U R                  XR                  5      nU R                  R                  U5      nU R                  R                  X25        g r   )
r  r  r.  r  r\   r  rR  r&  r  rw  )r   r%   r+   rs  s       r   r  Cache._save_overload  st    }}zz((..

,,.ooc<<0zz  &c(r   c              #      #    [         R                  S:X  a   S v   g S v   g ! [         a)  nUR                  [        R                  :w  a  e  S nAg S nAff = f7f)Nnt)rV   r  r   errnoEACCES)r   es     r   r  'Cache._guard_against_spurious_io_errors  sF     77d?   77ell* +s*   A" A
AAAAAc                 N   U R                   R                  R                  nU R                   R                  bE  [	        U R                   R                   Vs/ s H  oDR
                  PM     sn5      n[        U5      nOSnS nXR                  5       U" U5      U" U5      44$ s  snf )z
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                 J    [         R                  " U 5      R                  5       $ r   )rt   r   rw   )r>  s    r   <lambda>"Cache._index_key.<locals>.<lambda>  s    7>>!,668r   )r  r   co_code__closure__tuplecell_contentsr   magic_tuple)r   r%   rR  	codebytesr>  cvars	cvarbyteshashers           r   r  Cache._index_key  s     MM**22	==$$0DMM4M4MN4Mq??4MNOE eII8((*VI->-3I->-A B 	B Os   B")r  r   r  r  r  r  )r7   r8   r9   r:   r~   r  r   r  rN   r    r/   r2   r5   r'   r  r,   r  r  r  r  r  r;   r   r   r   r  r  k  sp    , KI    !<+)  Br   r  c                       \ rS rSrSr\rSrg)FunctionCachei  z>
Implements Cache that saves and loads CompileResult objects.
r   N)r7   r8   r9   r:   r~   r1  r  r;   r   r   r   r  r    s     )Kr   r  r  c                    ^ ^ T [         ;  d   e[         R                  T 5         " U 4S jS[        5      m " U4S jS[        5      nU$ )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                      > \ rS rSr Y rSrg)6make_library_cache.<locals>.CustomCodeLibraryCacheImpli  r   N)r7   r8   r9   r:   rY  r;   )prefixs   r   CustomCodeLibraryCacheImplr    s	    !r   r  c                       > \ rS rSrSr Y rSrg)(make_library_cache.<locals>.LibraryCachei  zu
Implements Cache that saves and loads CodeLibrary objects for additional
feature for the specified python function.
r   N)r7   r8   r9   r:   r~   r  r;   )r  s   r   LibraryCacher    s    	 1r   r  )_lib_cache_prefixesaddrK  r  )r  r  r  s   ` @r   make_library_cacher    sC     ,,,,F#"%9 "1u 1 r   )7r~   abcr   r   r   r  r  rt   r   ro  rV   r  r   rX   r  rF  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   r>   rP   objectr   r   r   r   r   r   r  r1  rK  r]  r  r  rm  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   