
    i}L              	          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JrJ	r	J
r
  S SKJr  S SKJr  S SKJrJr  S SKJrJrJrJrJrJr  S SKJr  S SKJr  S S	KJrJrJ r J!r!  S S
K"J#r#  S SK$J%r%  S r&SSS.r'0 SSS4S jr(S r)S r*S r+S r,S r-S r. " S S\%5      r/S r0S r1S r2S r3 " S S\Rh                  " S S!/5      5      r5 " S" S#\Rh                  " S#S$S!/5      5      r6S% r7g)&    N)typeserrorsutilsconfig)typeof_impl)as_numba_type)inferinfer_getattr)lower_builtinlower_getattrlower_getattr_genericlower_setattrlower_setattr_generic
lower_cast)models)register_default)boxunboxreflectNativeValue_import_cython_function)ReduceMixinc                    ^ ^^^^ SSK JmJmJm  [	        T 5      (       d   [        T [        5      (       d  [        S5      e T R                  mUU UUU4S jnU$ ! [         a    [        T 5      m N#f = f)z
Decorate a function as implementing typing for the callable *func*.
*func* can be a callable object (probably a global) or a string
denoting a built-in operation (such 'getitem' or '__array_wrap__')
r   )CallableTemplater	   infer_globalz%`func` should be a function or stringc                    >^  U 4S jnT< S3nT4n[        TUS9n[        X#U5      nT	" U5        [        T5      (       a  T
" T[        R                  " U5      5        T $ )Nc                 (   > T" U R                   5      $ N)context)selftyping_funcs    O/var/www/html/trading/venv/lib/python3.13/site-packages/numba/core/extending.pygeneric0type_callable.<locals>.decorate.<locals>.generic(   s    t||,,    _CallableTemplate)keyr$   )dicttypecallabler   Function)r"   r$   namebases
class_dicttemplater   func	func_namer	   r   s   `     r#   decoratetype_callable.<locals>.decorate'   s[    	- )23!#dG4
Z0hD>>u~~h78r&   )
numba.core.typing.templatesr   r	   r   r+   
isinstancestr	TypeError__name__AttributeError)r1   r3   r   r2   r	   r   s   ` @@@@r#   type_callabler;      sg    ; ;D>>*T3"7"7?@@MM	  O!  I	s   A A10A1T)no_cpython_wrappernopythonneverFc                    ^ ^^^^^^^	 SSK JmJm  [        R	                  5       m	T	R                  U5        U UUUUU	UU4S jnU$ )a	  
A decorator marking the decorated function as typing and implementing
*func* in nopython mode.

The decorated function will have the same formal parameters as *func*
and be passed the Numba types of those parameters.  It should return
a function implementing *func* for the given types.

Here is an example implementing len() for tuple types::

    @overload(len)
    def tuple_len(seq):
        if isinstance(seq, types.BaseTuple):
            n = len(seq)
            def len_impl(seq):
                return n
            return len_impl

Compiler options can be passed as an dictionary using the **jit_options**
argument.

Overloading strictness (that the typing and implementing signatures match)
is enforced by the **strict** keyword argument, it is recommended that this
is set to True (default).

To handle a function that accepts imprecise types, an overload
definition can return 2-tuple of ``(signature, impl_function)``, where
the ``signature`` is a ``typing.Signature`` specifying the precise
signature to be used; and ``impl_function`` is the same implementation
function as in the simple case.

If the kwarg inline determines whether the overload is inlined in the
calling function and can be one of three values:
* 'never' (default) - the overload is never inlined.
* 'always' - the overload is always inlined.
* a function that takes two arguments, both of which are instances of a
  namedtuple with fields:
    * func_ir
    * typemap
    * calltypes
    * signature
  The first argument holds the information from the caller, the second
  holds the information from the callee. The function should return Truthy
  to determine whether to inline, this essentially permitting custom
  inlining rules (typical use might be cost models).

The *prefer_literal* option allows users to control if literal types should
be tried first or last. The default (`False`) is to use non-literal types.
Implementations that can specialize based on literal values should set the
option to `True`. Note, this option maybe expanded in the near future to
allow for more control (e.g. disabling non-literal types).

**kwargs prescribes additional arguments passed through to the overload
template. The only accepted key at present is 'target' which is a string
corresponding to the target that this overload should be bound against.
r   )make_overload_templater   c                    > T" TU TT	TT40 TD6n[        U5        [        T5      (       a  T" T[        R                  " U5      5        U $ r   )r	   r+   r   r,   )
overload_funcr0   r1   r   inlinekwargsr@   optsprefer_literalstricts
     r#   r3   overload.<locals>.decorate   sM    )$tV*0.LDJLhD>>u~~h78r&   )r5   r@   r   _overload_default_jit_optionscopyupdate)
r1   jit_optionsrG   rC   rF   rD   r3   r   r@   rE   s
   ` ```` @@@r#   overloadrM   >   s7    t Q )--/DKK
  Or&   c                  ,   ^ U4S jnT(       a  U$ U" U 6 $ )a  
Register a regular python function that can be executed by the python
interpreter and can be compiled into a nopython function when referenced
by other jit'ed functions.  Can be used as::

    @register_jitable
    def foo(x, y):
        return x + y

Or, with compiler options::

    @register_jitable(_nrt=False) # disable runtime allocation
    def foo(x, y):
        return x + y

c                 X   >^  TR                  SS5      n[        T TUSS9U 4S j5       nT $ )NrC   r>   F)rL   rC   rG   c                     > T$ r    )argsrD   fns     r#   ov_wrap/register_jitable.<locals>.wrap.<locals>.ov_wrap   s    Ir&   )poprM   )rS   rC   rT   rD   s   `  r#   wrapregister_jitable.<locals>.wrap   s6    Hg.	"&	F	 
G		r&   rQ   )rR   rD   rW   s    ` r#   register_jitablerY      s    " T{r&   c                 ,   ^ ^^^ SSK Jm  UUUU 4S jnU$ )a  
A decorator marking the decorated function as typing and implementing
attribute *attr* for the given Numba type in nopython mode.

*kwargs* are passed to the underlying `@overload` call.

Here is an example implementing .nbytes for array types::

    @overload_attribute(types.Array, 'nbytes')
    def array_nbytes(arr):
        def get(arr):
            return arr.size * arr.itemsize
        return get
r   ) make_overload_attribute_templatec                 X   > T" TTU 40 TD6n[        U5        [        U 40 TD6" U 5        U $ r   )r
   rM   )rB   r0   attrrD   r[   typs     r#   r3   $overload_attribute.<locals>.decorate   s>    3}

 	h)&)-8r&   )r5   r[   )r^   r]   rD   r3   r[   s   ``` @r#   overload_attributer`      s      M  Or&   c                 ,   ^ ^^^ SSK Jm  UUUU 4S jnU$ )z=Common code for overload_method and overload_classmethod
    r   )make_overload_method_templatec                    > TR                  5       nT" TTU 4UR                  SS5      UR                  SS5      S.UD6n[        U5        [        U 40 TD6" U 5        U $ )NrC   r>   rF   F)rC   rF   )rJ   rV   r
   rM   )rB   copied_kwargsr0   r]   rD   rb   r^   s      r#   r3   )_overload_method_common.<locals>.decorate   sq    0}
 $$Xw7(,,-=uE
 	
 	h)&)-8r&   )r5   rb   )r^   r]   rD   r3   rb   s   ``` @r#   _overload_method_commonrf      s     J
 
 Or&   c                     [        X40 UD6$ )aq  
A decorator marking the decorated function as typing and implementing
method *attr* for the given Numba type in nopython mode.

*kwargs* are passed to the underlying `@overload` call.

Here is an example implementing .take() for array types::

    @overload_method(types.Array, 'take')
    def array_take(arr, indices):
        if isinstance(indices, types.Array):
            def take_impl(arr, indices):
                n = indices.shape[0]
                res = np.empty(n, arr.dtype)
                for i in range(n):
                    res[i] = arr[indices[i]]
                return res
            return take_impl
)rf   r^   r]   rD   s      r#   overload_methodri      s    ( #3777r&   c                 D    [        [        R                  " U 5      U40 UD6$ )a/  
A decorator marking the decorated function as typing and implementing
classmethod *attr* for the given Numba type in nopython mode.


Similar to ``overload_method``.


Here is an example implementing a classmethod on the Array type to call
``np.arange()``::

    @overload_classmethod(types.Array, "make")
    def ov_make(cls, nitems):
        def impl(cls, nitems):
            return np.arange(nitems)
        return impl

The above code will allow the following to work in jit-compiled code::

    @njit
    def foo(n):
        return types.Array.make(n)
)rf   r   TypeRefrh   s      r#   overload_classmethodrl      s    0 #5==#5tFvFFr&   c                 H  ^ ^^^^^^	^
 SSK Jn  SSKJm  SSKJm  SSKJm
  SSKJ	m  [        T [        5      (       a  [        T [        R                  5      (       d  [        ST < 35      eUUU4S jm	[          " U	UU 4S	 jS
U5      5       n[#        T T5      UU	U
U4S j5       ng)z
Make an automatic attribute wrapper exposing member named *struct_attr*
as a read-only attribute named *python_attr*.
The given *typeclass*'s model must be a StructModel subclass.
r   )AttributeTemplate)default_manager)StructModel)impl_ret_borrowed)cgutilsz)typeclass should be a Type subclass, got c                    > TR                  U 5      n[        UT5      (       d  [        SU< 35      eUR                  T5      $ )z6
Get the Numba type of member *struct_attr* in *typ*.
zImake_struct_attribute_wrapper() needs a type with a StructModel, but got )lookupr6   r8   get_member_fe_type)r^   modelrp   ro   struct_attrs     r#   get_attr_fe_type0make_attribute_wrapper.<locals>.get_attr_fe_type   sK      &&s+%--@EH I I''44r&   c                   *   > \ rS rSr YrU U4S jrSrg)/make_attribute_wrapper.<locals>.StructAttributei*  c                 "   > UT:X  a  T" U5      $ g r   rQ   )r!   r^   r]   rx   python_attrs      r#   generic_resolve?make_attribute_wrapper.<locals>.StructAttribute.generic_resolve.  s    {"',, #r&   rQ   N)r9   
__module____qualname____firstlineno__r(   r~   __static_attributes__)rx   r}   	typeclasss   r#   StructAttributer{   *  s    	- 	-r&   r   c                 j   > TR                  U5      " XUS9nT" U5      n[        UT	5      nT" XXE5      $ )N)value)create_struct_proxygetattr)
r    builderr^   valattrtyattrvalrr   rx   rq   rw   s
         r#   struct_getattr_impl3make_attribute_wrapper.<locals>.struct_getattr_impl2  s=    ))#.wsK!#&#{+ 6CCr&   N)r5   rn   numba.core.datamodelro   numba.core.datamodel.modelsrp   numba.core.imputilsrq   
numba.corerr   r6   r*   
issubclassr   Typer8   r
   r   )r   rw   r}   rn   r   r   rp   rr   ro   rx   rq   s   ```   @@@@@r#   make_attribute_wrapperr     s     >475"i&&jEJJ.O.O$' ( 	(5 - -+ - - 9k*D +Dr&   c                       \ rS rSrSr\R                  " 5       r\R                  " \
R                  S9rSrSS jr\S 5       rS rS rS	 rS
 rS rS r\S 5       rSrg)
_Intrinsici:  z
Dummy callable for intrinsic
)maxlenNc                 `    X@l         Xl        X l        X0l        [        R
                  " X5        g r   )_ctor_kwargs_name_defn_prefer_literal	functoolsupdate_wrapper)r!   r-   defnrF   rD   s        r#   __init___Intrinsic.__init__E  s&    "

-  ,r&   c                     U R                   nUc/  [        [        R                  " 5       5      nU R	                  U5        U$ )z
An instance-specific UUID, to avoid multiple deserializations of
a given instance.

Note this is lazily-generated, for performance reasons.
)_Intrinsic__uuidr7   uuiduuid1	_set_uuidr!   us     r#   _uuid_Intrinsic._uuidL  s3     KK9DJJL!ANN1r&   c                     U R                   b   eXl         X R                  U'   U R                  R                  U 5        g r   )r   _memo_recentappendr   s     r#   r   _Intrinsic._set_uuidZ  s4    {{"""

1D!r&   c                     SSK JnJn  U" X R                  U R                  U R
                  U R                  S9n[        U5        U" U [        R                  " U5      5        g )Nr   )make_intrinsic_templater   )rF   rD   )
r5   r   r   r   r   r   r   r	   r   r,   )r!   r   r   r0   s       r#   	_register_Intrinsic._register`  sN    	? +4TZZ:>:N:N262C2CE 	hT5>>(34r&   c                 :    SR                  U 5      n[        U5      e)z@
This is only defined to pretend to be a callable from CPython.
z {0} is not usable in pure-python)formatNotImplementedError)r!   rR   rD   msgs       r#   __call___Intrinsic.__call__k  s     177=!#&&r&   c                 8    SR                  U R                  5      $ )Nz<intrinsic {0}>)r   r   r!   s    r#   __repr___Intrinsic.__repr__r  s     ''

33r&   c                     U $ r   rQ   )r!   memos     r#   __deepcopy___Intrinsic.__deepcopy__u  s	     r&   c                 T    [        U R                  U R                  U R                  S9$ )$
NOTE: part of ReduceMixin protocol
)r   r-   r   )r)   r   r   r   r   s    r#   _reduce_states_Intrinsic._reduce_statesz  s     $**4::FFr&   c                      U R                   U   $ ! [         a,    U " X#S9nUR                  5         UR                  U5        Us $ f = f)r   )r-   r   )r   KeyErrorr   r   )clsr   r-   r   llcs        r#   _rebuild_Intrinsic._rebuild  sH    
	99T?" 	4+CMMOMM$J		s    3AA)__uuidr   r   r   r   )F)r9   r   r   r   __doc__weakrefWeakValueDictionaryr   collectionsdequer   FUNCTION_CACHE_SIZEr   r   r   propertyr   r   r   r   r   r   r   classmethodr   r   rQ   r&   r#   r   r   :  s     '')E v'A'ABGF-  "	5'4
G 
 
r&   r   c                  :   ^^ U4S jmT(       d  T" U 6 $ U4S jnU$ )a  
A decorator marking the decorated function as typing and implementing
*func* in nopython mode using the llvmlite IRBuilder API.  This is an escape
hatch for expert users to build custom LLVM IR that will be inlined to
the caller.

The first argument to *func* is the typing context.  The rest of the
arguments corresponds to the type of arguments of the decorated function.
These arguments are also used as the formal argument of the decorated
function.  If *func* has the signature ``foo(typing_context, arg0, arg1)``,
the decorated function will have the signature ``foo(arg0, arg1)``.

The return values of *func* should be a 2-tuple of expected type signature,
and a code-generation function that will passed to ``lower_builtin``.
For unsupported operation, return None.

Here is an example implementing a ``cast_int_to_byte_ptr`` that cast
any integer to a byte pointer::

    @intrinsic
    def cast_int_to_byte_ptr(typingctx, src):
        # check for accepted types
        if isinstance(src, types.Integer):
            # create the expected type signature
            result_type = types.CPointer(types.uint8)
            sig = result_type(types.uintp)
            # defines the custom code generation
            def codegen(context, builder, signature, args):
                # llvm IRBuilder code here
                [src] = args
                rtype = signature.return_type
                llrtype = context.get_value_type(rtype)
                return builder.inttoptr(src, llrtype)
            return sig, codegen
c                 l   > [        U S[        U 5      5      n[        X40 TD6nUR                  5         U$ )Nr9   )r   r7   r   r   )r1   r-   r   rD   s      r#   
_intrinsicintrinsic.<locals>._intrinsic  s2    tZT3.v.
r&   c                    > T" U 5      $ r   rQ   )r1   r   s    r#   wrapperintrinsic.<locals>.wrapper  s    d##r&   rQ   )rR   rD   r   r   s    ` @r#   	intrinsicr     s#    J 4  	$r&   c                     [        X5      $ )z
Get the address of a Cython function.

Args
----
module_name:
    Name of the Cython module
function_name:
    Name of the Cython function

Returns
-------
A Python int containing the address of the function

r   )module_namefunction_names     r#   get_cython_function_addressr     s      #;>>r&   c                      [         R                  R                  [         R                  R                  [        R                  5      5      n [         R                  R                  U 5      nU$ )z*Returns the C include directory path.
    )ospathdirnamenumba__file__abspath)include_dirr   s     r#   include_pathr     s>     ''//"''//%.."ABK77??;'DKr&   c                 ~  ^  T R                   " U0 UD6n[        5       nSn[        UR                  R	                  5       5       HC  u  nu  pX;   d  M  UR                  U5        [        U	[        R                  5      (       a  MA  SnME     U(       a-  [        R                  " U5      n
U 4S jnU
R                  U5      eg)a0  Ensures that the given argument types (in *args* and *kwargs*) are
literally typed for a function with the python signature *pysig* and the
list of literal argument names in *literal_args*.

Alternatively, this is the same as::

    SentryLiteralArgs(literal_args).for_pysig(pysig).bind(*args, **kwargs)
FTc                 n   > TR                   " U 0 UD6R                  R                  5       n[        U5      $ r   )bind	argumentsvaluestuple)rR   rD   outpysigs      r#   folded#sentry_literal_args.<locals>.folded  s/    **d-f-77>>@C:r&   N)r   set	enumerater   itemsaddr6   r   Literalr   ForceLiteralArgbind_fold_arguments)r   literal_argsrR   rD   	boundargsrequest_posmissingikver   s   `           r#   sentry_literal_argsr    s     

D+F+I %KGy2288:;	6AOOAa//	 <
 "";/	 ##F++ r&   c                   $    \ rS rSrSrS rS rSrg)SentryLiteralArgsi  a%  
Parameters
----------
literal_args : Sequence[str]
    A sequence of names for literal arguments

Examples
--------

The following line:

>>> SentryLiteralArgs(literal_args).for_pysig(pysig).bind(*args, **kwargs)

is equivalent to:

>>> sentry_literal_args(pysig, literal_args, args, kwargs)
c                 L    U R                  [        R                  " U5      5      $ )zBind the sentry to the signature of *func*.

Parameters
----------
func : Function
    A python function.

Returns
-------
obj : BoundLiteralArgs
)	for_pysigr   pysignature)r!   r1   s     r#   for_functionSentryLiteralArgs.for_function  s     ~~e//566r&   c                 *    [        UU R                  S9$ )zBind the sentry to the given signature *pysig*.

Parameters
----------
pysig : inspect.Signature


Returns
-------
obj : BoundLiteralArgs
)r   r   )BoundLiteralArgsr   )r!   r   s     r#   r	  SentryLiteralArgs.for_pysig  s      **
 	
r&   rQ   N)r9   r   r   r   r   r  r	  r   rQ   r&   r#   r  r    s    "7
r&   r  _SentryLiteralArgsr   c                       \ rS rSrSrS rSrg)r  i1  z5
This class is usually created by SentryLiteralArgs.
c                 F    [        U R                  U R                  UU5      $ )z Bind to argument types.
        )r  r   r   )r!   rR   rD   s      r#   r   BoundLiteralArgs.bind6  s'     #JJ	
 	
r&   rQ   N)r9   r   r   r   r   r   r   rQ   r&   r#   r  r  1  s    
r&   r  r   c                 $    SSK Jn  [        X5      $ )zReturns True if a function is wrapped by one of the Numba @jit
decorators, for example: numba.jit, numba.njit

The purpose of this function is to provide a means to check if a function is
already JIT decorated.
r   )
Dispatcher)numba.core.dispatcherr  r6   )functionr  s     r#   	is_jittedr  A  s     1h++r&   )8r   r   r   r   r   r   r   r   r   r   r   numba.core.typing.typeofr   numba.core.typing.asnumbatyper   r5   r	   r
   r   r   r   r   r   r   r   r   r   r   register_modelnumba.core.pythonapir   r   r   r   numba._helperlibr   numba.core.serializer   r;   rI   rM   rY   r`   rf   ri   rl   r   r   r   r   r   r  
namedtupler  r  r  rQ   r&   r#   <module>r      s    	      3 3 1 7 <6 6 ( C A A 4 ,D 8<,0!2   "$w!K\@<(8.G6'DTQ Qh3l?&,>0
..~.0 0
f
{--Wn57 
 
,r&   