
    sh                     4   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  S SKJr  S SKJrJr  S SKJr  \" S	/ S
Q5      r " S S\5      r\R,                  r\R0                  " \5      S 5       r\R4                  " 5         \" 5       r\" \\R8                  5        Cg)    )
namedtuple)finalize)	nrtdynmod)binding)global_compiler_lock)typeof_impl)typesconfig)_nrt_python
nrt_mstatsallocfreemi_allocmi_freec                   f    \ rS rSrS r\S 5       rS r\S 5       r	\
S 5       rS rSS jrS	 rS
rg)_Runtime   c                     SU l         g )NF)_initselfs    j/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/runtime/nrt.py__init___Runtime.__init__   s	    
    c                 |   U R                   (       a  g[        R                  (       a  [        R                  " 5         [        R
                   HJ  nUR                  S5      (       a  UnOSU-   n[        R
                  U   n[        R                  " X45        ML     [        R                  " U5      U l        SU l         g)zmInitializes the NRT

Must be called before any actual call to the NRT API.
Safe to be called multiple times.
N_NRT_T)r   r
   	NRT_STATS_nrtmemsys_enable_stats	c_helpers
startswithll
add_symbolr   compile_nrt_functions_library)r   ctxpy_namec_name	c_addresss        r   
initialize_Runtime.initialize   s     :: $$& ~~G!!#&& ')w/IMM&, & "77<
r   c                 @    U R                   (       d  Sn[        U5      eg )Nz'Runtime must be initialized before use.)r   RuntimeError)r   msgs     r   _init_guard_Runtime._init_guard0   s    zz;Cs## r   c                  .    [         R                  " 5         g)zM
Shutdown the NRT
Safe to be called without calling Runtime.initialize first
N)r!   memsys_shutdown r   r   shutdown_Runtime.shutdown5   s     	r   c                 :    U R                  5         U R                  $ )zA
Return the Library object containing the various NRT functions.
)r2   r(   r   s    r   library_Runtime.library=   s    
 	}}r   c                 d    U R                  5         [        R                  " X5      n[        U5      $ )z
Returns a MemInfo object that tracks memory at `data` owned by `pyobj`.
MemInfo will acquire a reference on `pyobj`.
The release of MemInfo will release a reference on `pyobj`.
)r2   r!   meminfo_newMemInfo)r   datapyobjmis       r   r=   _Runtime.meminfo_newE   s*     	d*r{r   c                     U R                  5         US:  a  SU S3n[        U5      eU(       a  [        R                  " U5      nO[        R                  " U5      nUS:X  a  SU S3n[        U5      e[        U5      $ )au  
Allocate a new memory of `size` bytes and returns a MemInfo object
that tracks the allocation.  When there is no more reference to the
MemInfo object, the underlying memory will be deallocated.

If `safe` flag is True, the memory is allocated using the `safe` scheme.
This is used for debugging and testing purposes.
See `NRT_MemInfo_alloc_safe()` in "nrt.h" for details.
r   z,Cannot allocate a negative number of bytes: .zRequested allocation of z bytes failed.)r2   
ValueErrorr!   meminfo_alloc_safememinfo_allocMemoryErrorr>   )r   sizesafer1   rA   s        r   rG   _Runtime.meminfo_allocO   s|     	!8@aHCS/!((.B##D)B7,TF.ACc""r{r   c                     [        [        R                  " 5       [        R                  " 5       [        R                  " 5       [        R
                  " 5       S9$ )z_
Returns a namedtuple of (alloc, free, mi_alloc, mi_free) for count of
each memory operations.
r   )_nrt_mstatsr!   memsys_get_stats_allocmemsys_get_stats_freememsys_get_stats_mi_allocmemsys_get_stats_mi_freer   s    r   get_allocation_stats_Runtime.get_allocation_statsf   sB     !<!<!> $ : : <$($B$B$D#'#@#@#BD 	Dr   )r   r(   N)F)__name__
__module____qualname____firstlineno__r   r   r-   r2   staticmethodr7   propertyr:   r=   rG   rR   __static_attributes__r6   r   r   r   r      sX      8$
    .	Dr   r   c                 J    [         R                  " [         R                  5      $ )N)r	   MemInfoPointervoidptr)valcs     r   typeof_meminfor`   v   s    ..r   N)collectionsr   weakrefr   	_finalizenumba.core.runtimer   llvmliter   r%   numba.core.compiler_lockr   numba.core.typing.typeofr   
numba.corer	   r
   r   r!   rM   objectr   _MemInfor>   registerr`   memsys_use_cpython_allocatorrtsysr7   r6   r   r   <module>rn      s    " ) ( " 9 0 $ 2'OP`Dv `DH -- g/ /
  ! ! #
 
%"" # r   