
    xKg=                        d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZmZ ddlmZ dd	lmZmZ  eej2                        d
        Z eej2                        d        Z eej8                         eej:                        d               Z eej>                        d        Z  eej>                        d        Z! eejD                        d        Z# eejD                        d        Z$ eejJ                        d        Z& eejJ                        d        Z' eejP                        d        Z) eejP                         eejT                        d               Z+ eejX                        d        Z- eejX                        d        Z. eej^                        d        Z0 eej^                        d        Z1 eejd                        d        Z3 eejh                        d        Z5 eejh                        d        Z6 eejn                        d        Z8 eejr                        d        Z: eejr                        d        Z; eejx                        d        Z= eejx                        d         Z> eej~                        d!        Z@ eej                        d"        ZB eej                        d#        ZC eej                        d$        ZE eej                        d%        ZF eej                        d&        ZH eej                        d'        ZJ eej                        d(        ZL eej                        d)        ZN eej                        d*        ZP eej                        d+        ZQ eej                         eej                        d,               ZT eej                         eej                        d-               ZW eej                        d.        ZY eej                        d/        Z[ G d0 d1e\      Z]d2 Z^ eej                        d3        Z_ e	ej                        d4        Z`d5 Za eej                        d6        Zcd7 Zd eej                        d8        Ze e	ej                        d9        Zf eej                        d:        Zh eej                        d;        Zi eej                        d<        Zk eej                        d=        Zl eej                        d>        Zn eej                        d?        Zo eej                         eej                        d@               Zr eej                         eej                        dA               Zs eej                        dB        Zu eej                        dC        Zw eej                        dD        Zx eej                        dE        Zz eej                        dF        ZrdG Z{dH Z| eej                        dI        Z~ eej                        dJ        Z eej                        dK        Z eej                        dL        Z eej                        dM        Z eej                        dN        Z ej                  dO      Z eej                        dP        Z eej                        dQ        ZyR)SzG
Boxing and unboxing of native Numba values to / from CPython objects.
    )ir)typescgutils)boxunboxreflectNativeValue)NumbaNotImplementedErrorTypingError)typeofPurpose)setobjlistobj)numpy_support)contextmanager	ExitStackc                 8    |j                   j                  |      S N)pyapibool_from_booltypvalcs      U/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/boxing.pybox_boolr      s    77!!#&&    c                     |j                   j                  |      }t        j                  |j                  d      }|j
                  j                  d||      }t        ||j                   j                               S )Nr   !=is_error)	r   object_istruer   Constanttypebuildericmp_signedr	   c_api_error)r   objr   istruezeror   s         r   unbox_booleanr+      s\    WW""3'F;;v{{A&D
))

fd
3CsQWW%8%8%:;;r   c                     |j                   j                  |j                  || | j                        }|j	                  | j                  |      S r   )contextcastr%   literal_typer   r   s      r   box_literal_integerr0   !   s=     ))..Cc.>.>
?C55!!3''r   c                 F   | j                   rK|j                  j                  ||j                  j                        }|j                  j                  |      S |j                  j                  ||j                  j                        }|j                  j                  |      S r   )	signedr%   sextr   longlonglong_from_longlongzext	ulonglonglong_from_ulonglong)r   r   r   ivalullvals        r   box_integerr;   (   so    
zzyy~~c177#3#34ww))$//QWW%6%67ww**622r   c                    |j                   j                  |       }t        j                  |j                  |      }|j
                  j                  |      }|j
                  j                  |      5  | j                  r|j
                  j                  |      }n|j
                  j                  |      }|j
                  j                  |       |j                  j                  |j                  j                  ||      |       d d d        t        |j                  j                  |      |j
                  j!                               S # 1 sw Y   GxY wNr    )r-   get_argument_typer   alloca_oncer%   r   number_longif_object_okr2   long_as_longlonglong_as_ulonglongdecrefstoretruncr	   loadr'   )r   r(   r   ll_typer   longobjllvals          r   unbox_integerrK   1   s    ii))#.G


aii
1Cgg!!#&G	
		g	&::GG,,W5EGG--g6E	w					w7= 
' qyy~~c* ! 3 3 57 7 
'	&s   2BEEc                     | t         j                  k(  r1|j                  j                  ||j                  j
                        }n| t         j                  k(  sJ |}|j                  j                  |      S r   )r   float32r%   fpextr   doublefloat64float_from_double)r   r   r   dbvals       r   	box_floatrS   A   sV    
emm		QWW^^4emm###77$$U++r   c                    |j                   j                  |      }|j                   j                  |      }|j                   j                  |       | t        j
                  k(  r6|j                  j                  ||j                  j                  |             }n| t        j                  k(  sJ |}t        ||j                   j                               S r=   )r   number_floatfloat_as_doublerD   r   rM   r%   fptruncr-   r>   rP   r	   r'   )r   r(   r   fobjrR   r   s         r   unbox_floatrY   J   s    77$DGG##D)EGGNN4
emmii !		 ; ;C @B emm###sQWW%8%8%:;;r   c                    |j                   j                  |j                  | |      }| t        j                  k(  ru|j                  j                  |j                  |j                  j                        }|j                  j                  |j                  |j                  j                        }n-| t        j                  k(  sJ |j                  |j                  }}|j                  j                  ||      S Nvalue)r-   make_complexr%   r   	complex64rN   realr   rO   imag
complex128complex_from_doubles)r   r   r   cvalfrealfimags         r   box_complexrg   X   s    99!!!))S!<D
eoo				177>>:				177>>:e&&&&&yy$))u77''u55r   c                    |j                   j                  |j                  t        j                        }|j
                  j                  ||j                               }t        j                  |j                  |      }t        j                  |j                  |      5  |j
                  j                  dd| d       d d d        | t        j                  k(  r|j                   j                  |j                  |       }|j                   j                  |j                  |j                  t        j                  t        j                         |_        |j                   j                  |j                  |j"                  t        j                  t        j                         |_        n| t        j                  k(  sJ |}t%        |j'                         |      S # 1 sw Y   xY w)NPyExc_TypeErrorzconversion to z failedr    )r-   r^   r%   r   rb   r   complex_adaptor_getpointerr   is_falseif_unlikelyerr_set_stringr_   r.   r`   rP   rM   ra   r	   	_getvalue)r   r(   r   c128okfailedcplxs          r   unbox_complexrt   d   sJ    99!!!))U-=-=>D	
	 	 d&6&6&8	9Baii,F			QYY	/	0<?A	C 
0 eooyy%%aii5IINN199dii#(==%--A	IINN199dii#(==%--A	 e&&&&&t~~'&99 
0	/s   !GG$c                 6    |j                   j                         S r   )r   	make_noner   s      r   box_nonerw   |   s    77r   c                 H    t        |j                  j                               S r   r	   r-   get_dummy_valuer   s      r   
unbox_noner{           qyy00233r   c                 N    |j                   j                  || j                        S r   )r   create_np_datetime	unit_coder   s      r   box_npdatetimer      s    77%%c3==99r   c                     |j                   j                  |      }t        ||j                   j                               S r=   )r   extract_np_datetimer	   r'   r   r(   r   r   s       r   unbox_npdatetimer      s0    
''
%
%c
*CsQWW%8%8%:;;r   c                 N    |j                   j                  || j                        S r   )r   create_np_timedeltar   r   s      r   box_nptimedeltar      s    77&&sCMM::r   c                     |j                   j                  |      }t        ||j                   j                               S r=   )r   extract_np_timedeltar	   r'   r   s       r   unbox_nptimedeltar      s0    
''
&
&s
+CsQWW%8%8%:;;r   c                     |j                   j                  t        j                        }|j                  j                  ||      }|j                  t        j                  |      S )z0
    Convert a raw pointer to a Python int.
    )r-   get_value_typer   uintpr%   ptrtointr   )r   r   r   ll_intpaddrs        r   box_raw_pointerr      sG    
 ii&&u{{3G99c7+D55d##r   c                     |j                  | j                  |      }|j                  j                  |j                  j	                  | j
                              }|j                  j                  ||f      S )z6
    Fetch an enum member given its native value.
    )r   dtyper   unserializeserialize_objectinstance_classcall_function_objargs)r   r   r   valobjcls_objs        r   box_enumr      sZ    
 UU399c"Fgg!!!''":":3;M;M"NOG77((6)<<r   c                 r    |j                   j                  |d      }|j                  | j                  |      S )z=
    Convert an enum member's value to its native value.
    r]   )r   object_getattr_stringr   r   )r   r(   r   r   s       r   
unbox_enumr      s/    
 WW**38F77399f%%r   c                     d}t        |      )z7This type cannot be boxed, there's no Python equivalentzJUndefVar type cannot be boxed, there is no Python equivalent of this type.)r   )r   r   r   msgs       r   box_undefvarr      s    C
c
r   c                 x   t        j                  t        j                  d      |j                  j                  j
                        }|j                  j                  |t        j                  t        j                  d                  }|j                  j                  ||| j                  |j                        S )N       )r   r#   IntTyper$   pointeecountr%   bitcastPointerTyper   recreate_recordr   env_manager)r   r   r   sizeptrs        r   
box_recordr      sv     ;;rzz"~sxx'7'7'='=>D
))

C

1!>
?C77""3ciiGGr   c                 H   j                   j                         j                   j                  |      }t        j                  j
                  |      }j                  j                  |       }j
                  j                  ||      }fd}t        |||      S )Nc                  <    j                   j                          y r   r   release_bufferbufr   s   r   cleanupzunbox_record.<locals>.cleanup       	s#r   r   r!   )
r   alloca_bufferextract_record_datar   is_nullr%   r-   r   r   r	   )	r   r(   r   r   r!   ltypr   r   r   s	     `     @r   unbox_recordr      s}    
''


!C
''
%
%c3
/Cqyy#.H99##C(D
))

C
&C$sGh??r   c           
      f   |j                   j                  |j                   j                  |j                   j                  dt        j
                     }|j                  j                  t        j                  |      }t        j                  |j                  |      }|j                  j                  ||j                   j                        }|j                  j                  t        j                  | j                         }|j#                  d      }|j#                  d      }	|j#                  t        j
                        }
t        j                  |j                  |      }t        j$                  |j                  |g|j"                        5 \  }|j                  j'                  |j                  j)                  ||j                  j+                  ||
      g            }|j                  j-                  t        j.                  |j                  |            5  |j                  j1                  |j                  j3                  ||	      |       d d d        d d d        |j                  j'                  |      }|j                   j5                  |||      S # 1 sw Y   IxY w# 1 sw Y   MxY w)N)         r\   r   r   )r   py_unicode_1byte_kindpy_unicode_2byte_kindpy_unicode_4byte_kindr   sizeof_unicode_charr-   get_constantr   int32r   alloca_once_valuer%   r   cstringintpr   r$   	loop_nestrG   gepmulif_thenis_not_nullrE   addstring_from_kind_and_data)r   r   r   unicode_kindkindrawptrstrptrfullsizer*   onestepr   idxchstrlens                  r   box_unicodecharseqr      s    77((77((77((* +8*K*KML 99!!%++|<D&&qyy<FYYvqww7Fyy%%ejj#))<H==D
--
C==::;D%%aii6E			199xj(--	@ESYY^^AIIMM&199==d3K2LMNYYw22199bABIIOOAIIMM#s3U; C	 
A YY^^E"F77,,T66BB CB	 
A	@s%   BJ'7JJ'J$	 J''J0c                 (   |j                   j                  |       }|j                  j                  |      \  }}}}}}	t	        j
                  |j                  |      5  t        j                  |j                  | j                        }
|j                  j                  d||
      }|j                  j                  |||
      }t        j                  |d       }t	        j                  |j                  |      }t	        j                  |j                  |j                  j                  ||j                        ||       d d d        |j                  j!                        }t#        ||j                  j%                  |            S # 1 sw Y   JxY wNz<=r    )r-   r   r   string_as_string_size_and_kindr   	if_likelyr%   r   r#   r$   r   icmp_unsignedselectr   memcpyr   rG   r	   not_)r   r(   r   ltyrq   bufferr   r   is_asciihashvstorage_size	size_fitsnull_stringoutspacerets                  r   unbox_unicodecharseqr      s0   
))
"
"3
'C 	
..s3 ,BdHe 
		199b	){{499cii8II++D$E	 yy	4> kk#t,--aiiE 	qyy		))(FKK@	& 
*$ ))..
"CsQYY^^B%788' 
*	)s   C!FFc                    |j                   j                  |j                  | |      }|j                  j	                  |j
                  |j                        }|j                   j                  j                  |j                  | |       |S r   )	r-   make_helperr%   r   bytes_from_string_and_sizedatanitemsnrtrD   )r   r   r   r(   r   s        r   	box_bytesr     s_    
))

		3
4C
''
,
,SXXszz
BCIIMMC-Jr   c                    t        j                  |j                  |      }|j                  j                  ||j                  j
                        }|j                  j                  t        j                  | j                        }|j                  d      }|j                  d      }t        j                  |j                  |      }t        j                  |j                  |g|j                        5 \  }	|j                  j                  |j                  j                  ||	g            }
|j                  j                  t        j                   |j                  |
            5  |j                  j#                  |j                  j%                  |	|      |       d d d        d d d        |j                  j                  |      }|j                  j'                  ||      S # 1 sw Y   HxY w# 1 sw Y   LxY w)Nr\   r   r   )r   r   r%   r   r   r   r-   r   r   r   r   r$   r   rG   r   r   r   rE   r   r   )r   r   r   r   r   r   r*   r   r   r   r   r   s               r   box_charseqr     sZ   &&qyy<FYYvqww7Fyy%%ejj#))<H==D
--
C%%aii6E
 
		199xj(--	@ESYY^^AIIMM&3%89YYw22199bABIIOOAIIMM#s3U; C	 
A YY^^E"F77--ff==	 CB	 
A	@s%   4A2G0&7G$G0$G-	)G00G9c                 "   |j                   j                  |       }|j                  j                  |      \  }}}t	        j
                  |j                  |      5  t        j                  |j                  | j                        }|j                  j                  d||      }|j                  j                  |||      }t        j                  |d       }	t	        j                  |j                  |	      }
t	        j                  |j                  |j                  j                  |
|j                        ||       d d d        |j                  j!                  
      }t#        ||j                  j%                  |            S # 1 sw Y   JxY wr   )r-   r   r   string_as_string_and_sizer   r   r%   r   r#   r$   r   r   r   r   r   r   rG   r	   r   )r   r(   r   r   rq   r   r   r   r   r   r   r   s               r   unbox_charseqr   1  s&   
))
"
"3
'Cww88=B 
		199b	){{499cii8II++D$E	 yy	4> kk#t,--aiiE 	qyyyy((6;;?t	% 
*$ ))..
"CsQYY^^B%788' 
*	)s   C!FFc                    |j                   j                  |j                  | |      }t        j                  |j                  |j
                  j                               }|j                  j                  |j                        5 \  }}|5  |j                  | j                  |j                        }|j                  j                  ||       d d d        |5  |j                  j                  |j
                  j                         |       d d d        d d d        |j                  j                  |      S # 1 sw Y   kxY w# 1 sw Y   8xY w# 1 sw Y   <xY wr   )r-   r   r%   r   r   r   borrow_noneif_elsevalidr   r$   r   rE   rv   rG   )r   r   r   optvalr   then	otherwisevalidress           r   box_optionalr  M  s    YY""199c37F

#
#AIIqww/B/B/D
EC	
		6<<	(,=T9uuSXXv{{3HIIOOHc*  IIOOAGG--/5 	 
) 99>># T Y	 
)	(s=   EAD8
E5EE8E	=EE		EEc                 ^   j                   j                  j                  | j                        }j                  j	                  d|j
                  j                               t        j                  j                  |j                        }t        j                  j                  t        j                        }j                  j                        5 \  }}|5  j                  | j                  |      j                   j                  j                  | j                  j                        }j                  j                  ||       j                  j                  j                   |       ddd       |5  j                  j                  ||       ddd       ddd       j"                  fd}	nd}	j                  j%                  |      }
t'        |
j                  j%                  |      |	      S # 1 sw Y   xY w# 1 sw Y   uxY w# 1 sw Y   yxY w)z>
    Convert object *obj* to a native optional structure.
    r   Nc                       j                   j                        5  j                          d d d        y # 1 sw Y   y xY wr   )r%   r   r   )r   is_not_nonenatives   r   r   zunbox_optional.<locals>.cleanupq  s+    "";/  0//s	   7A r!   r   )r-   make_optional_noner%   r$   r&   r   r   r   r?   r   	false_bitr   r   make_optional_valuer]   rE   r!   r   rG   r	   )r   r(   r   nonevalretptrerrptrr   orelsejustr   r   r  r  s     `        @@r   unbox_optionalr  Z  s   
 ii**199chh?G))''c1773F3F3HIK  GLL9F&&qyy'2C2CDF	
		;	'>D&WWSXXs+F9900146<<IDIIOOD&)IIOOFOOV4  IIOOGV,  
( ~~!	! 
))..
 CsQYY^^F%;&( (% T V 
(	's=   H#"BH<
H#H#H#H	H#H 	H##H,c                 ,   ddl m} |j                  j                  |      \  }}}}|j                  j                  |j                  |       }||_        ||_        ||_	        t        |j                         |j                  j                  |            S )z;
    Convert object *obj* to a native slice structure.
    r   )slicingr    )numba.cpythonr  r   slice_as_intsr-   r   r%   startstopr   r	   ro   r   )	r   r(   r   r  rq   r  r  r   slis	            r   unbox_slicer  |  ss    
 &GG11#6BtT
))

		3
/CCICHCHs}}1CDDr   c           
         | j                   }dD ]0  }t        ||      }t        |t              s 	 t	        |t
               2 | j                   j                         \  }}|j                  j                  |      }	|j                  j                  |      }
|j                  j                  |	      }|j                  j                  |
      }|j                  j                  ||      }|j                  j                  |       |j                  j                  |       |S # t        $ r}t        d| dt        |             d }~ww xY w)N)r  r  r   z7Unable to create literal slice. Error encountered with z attribute. )literal_valuegetattr
isinstanceintr   r   
ValueErrorstr
__reduce__r   r   r   callrD   )r   r   r   	slice_lit
field_name	field_objepy_ctorpy_argsserialized_ctorserialized_argsctorargsr(   s                 r   box_slice_literalr+    s    !!I/
Iz2	i%y'*	 0 ((335GWgg..w7Ogg..w7O77/D77/D
'',,tT
"CGGNN4GGNN4J   ..8\ :""%a&+ s   D	E(EEc                 H    t        |j                  j                               S r   ry   r   r(   r   s      r   unbox_string_literalr.    r|   r   c                 :   |j                   j                  |       } ||j                   |j                  |      }|j                   j                  rt	        j
                  | j                        }|j                  j                  |j                  j                  |            }|j                  j                  | ||      }|j                   j                  j                  |j                  | |       |S |j                  }|j                  j                  |       |S r[   )r-   
make_arrayr%   
enable_nrtr   as_dtyper   r   
read_const	add_constr   nrt_adapt_ndarray_to_pythonr   rD   parentincref)	r   r   r   nativearycls	nativearynp_dtypedtypeptrnewaryr6  s	            r   	box_arrayr=    s    99'',LQYY		=Iyy ))#))4==++AMM,C,CH,MN44S#xH			QYYS1!!	vr   c                 6  
 j                   j                         
j                   j                  |
      }t        j                  j
                  |      }j                  j                  |       } |j                  j
                        }|j                         }t        j                  j
                  j
                  j                  |            5  j
                  j                  |j                   j                        }j                  j                  rj                   j                  
|       nj                   j                  
|       ddd       
fd}	t!        j
                  j#                  |      ||	      S # 1 sw Y   6xY w)zK
    Convert a Py_buffer-providing object to a native array structure.
    Nc                  <    j                   j                          y r   r   r   s   r   r   zunbox_buffer.<locals>.cleanup  r   r   r  )r   r   
get_bufferr   r   r%   r-   r0  rk   r   r   r   voidptrr1  nrt_adapt_buffer_from_pythonnumba_buffer_adaptorr	   rG   )r   r(   r   resr!   r8  r9  aryptrr   r   r   s     `       @r   unbox_bufferrF    s%   
 ''


!C
''

S#
&C""199c2H99'',LQYY		2I""$F			199aiinnX&>	?ii899GG00c:GG((c2 
@$ qyy~~f-&( ( 
@	?s   B FFc                    |j                   j                  |       } ||j                   |j                        }|j                         }|j                  j	                  ||j
                  j                        }|j                   j                  r|j
                  j                  ||      }n|j
                  j                  ||      }	 t        j                  | j                        j                  }|j                  j                  |      }|j                  j                  d|j                  |      }	|j                  j'                  t#        j(                  |j                  |      |	      }
|j                  j+                  |
d      5  |j
                  j-                  dd       ddd       t/        |j                  j1                  |      |
      S # t         $ r t"        j$                  }	Y w xY w# 1 sw Y   NxY w)zC
    Convert a Numpy array object to a native array structure.
    r   Flikelyri   zXcan't unbox array from PyObject into native value.  The object maybe of a different typeNr    )r-   r0  r%   rk   r   r   rA  r1  nrt_adapt_ndarray_from_pythonnumba_array_adaptorr   r2  r   itemsizer$   r   r
   r   r  or_r   r   rn   r	   rG   )r   r(   r   r8  r9  rE  r   errcodeexpected_itemsizeitemsize_mismatchrr   s              r   unbox_arrayrQ    s    99'',LQYY		2I""$F
))

FAGGOO
4Cyy''77SA''--c37)22399=FF
 &..334EFII33 YY]]AIIw/F
 
		6%		0	0 0	1 
1
 qyy~~f-??+ $ .#--.  
1	0s   	)G G5G21G25G>c                    |j                   j                  | j                        }t        |       D ]P  \  }}|j                  j                  ||      }|j                  ||      }|j                   j                  |||       R |S )zD
    Convert native array or structure *val* to a tuple object.
    )r   	tuple_newr   	enumerater%   extract_valuer   tuple_setitem)r   r   r   	tuple_valir   itemr(   s           r   	box_tuplerZ  
  sr     !!#)),IcN5yy&&sA.eeE4 	iC0 #
 r   c                 @   |j                   j                  |j                   j                  | j                              }t	        | ||      }|j                   j                  ||      }|j                   j                  |       |j                   j                  |       |S )zI
    Convert native array or structure *val* to a namedtuple object.
    )r   r   r   r   rZ  r   rD   )r   r   r   r   	tuple_objr(   s         r   box_namedtupler]    st     gg!!!''":":3;M;M"NOG#sA&I
'',,w	
*CGGNN7GGNN9Jr   c                     t        |       }g }g |j                  j                  |       }t        j                  |j
                  t        j                        }t        j                  |j
                  |      }|j                  j                  |      }|j
                  j                  d|t        j                  |j                  |            }	|j
                  j                  |j
                  j                  |	      d      5  |j                  j!                  dd|fz  |       |j
                  j#                  t        j$                  |       ddd       t'        |       D ]  \  }
}|j                  j)                  ||
      }|j+                  ||      }|j-                  |j.                         |j
                  j                  |j0                  d      5  |j
                  j#                  t        j$                  |       ddd       |j2                  j-                  |j2                          |j                  j5                  |j
                  | |      }|j
                  j#                  ||       r,|j
                  j                  |	d      5  fd}ddd       nd}t7        |j
                  j9                  |      |j
                  j9                  |      	      S # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   bxY w)
zN
    Convert tuple *obj* to a native array (if homogeneous) or structure.
    z==FrH  PyExc_ValueErrorz<size mismatch for tuple, expected %d element(s) but got %%zdNTc                  4    t              D ]	  }  |          y r   )reversed)funccleanupss    r   r   zunbox_tuple.<locals>.cleanupO  s    $X.DF /r   r   )lenr-   r   r   r   r%   r  r?   r   
tuple_sizer   r   r#   r$   r   r   
err_formatrE   true_bitrT  tuple_getitemr   appendr]   r!   r   
make_tupler	   rG   )r   r(   r   nvaluesr   is_error_ptr	value_ptractual_sizesize_matchesrX  eltypeelemr  r]   r   rc  s                   @r   unbox_tuplers  '  sK   
 	CAFH
))
"
"3
'C,,QYY8I8IJL##AIIs3I ''$$S)K99**4,.KK8H8H!,LNL	
		199>>,7		F	JaTQ	 	
		((,7 
G s^	6ww$$S!,&fll#YYvu=IIOOG,,l; >>>%OOFNN+ $ II  C8EIIOOE9%YY|D9 :9
 qyy~~i0' !		| <> >; 
G	F >= :9s%   AK++K8L+K58L	Lc           	         t        j                  |j                  |j                  | |      }|j                  }t        j                  |j                  |      }|j                  j                  t        j                  |j                  |            5 \  }}|5  |j                  j                  |       ddd       |5  |j                  }|j                  j                  |      }|j                  j                  t        j                  |j                  |      d      5  t        j                  |j                  |      5 }	|j                  |	j                         }
|j#                  |
       |j%                  | j&                  |
      }|j                  j)                  ||	j                   |       ddd       ddd       |j                  j+                  ||       ddd       ddd       |j                  j,                  j/                  |j                  | |       |j                  j1                  |      S # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)z5
    Convert native list *val* to a list object.
    NTrH  )r   ListInstancer-   r%   r6  r   r   r   r   r   r7  r   list_newr   	for_rangegetitemindexincref_valuer   r   list_setitemrE   r   rD   rG   )r   r   r   listr(   rD  
has_parentr   r   looprY  itemobjs               r   box_listr  Y  s   
 		199c3?D
++C

#
#AIIs
3C	
		7..qyy#>	?CZJPY GGNN3	  YYF''""6*C""7#6#6qyy##F*. # 0&&qyy&9T<<

3D%%d+eeCIIt4GGG((djj'B	 :0 IIOOC%  
@, IIMMC-99>>#- Z :90 0	 Y 
@	?sn   I+H:4
I+>A#I!!IA0I	2I:$II+:I	?I+IIIII(	$I++I4c                   (    e Zd ZdZd Zd Zd Zd Zy)_NumbaTypeHelpera  A helper for acquiring `numba.typeof` for type checking.

    Usage
    -----

        # `c` is the boxing context.
        with _NumbaTypeHelper(c) as nth:
            # This contextmanager maintains the lifetime of the `numba.typeof`
            # function.
            the_numba_type = nth.typeof(some_object)
            # Do work on the type object
            do_checks(the_numba_type)
            # Cleanup
            c.pyapi.decref(the_numba_type)
        # At this point *nth* should not be used.
    c                     || _         y r   )r   )selfr   s     r   __init__z_NumbaTypeHelper.__init__  s	    r   c                 0   | j                   }|j                  j                  |j                  j                  d      }|j
                  j                  |      }|j
                  j                  |d      }|| _        |j
                  j                  |       | S )Nnumbar   )
r   r-   insert_const_stringr%   moduler   import_module_noblockr   	typeof_fnrD   )r  r   
numba_name	numba_modr  s        r   	__enter__z_NumbaTypeHelper.__enter__  sq    FFYY221993C3CWM
GG11*=	GG11)XF	"	y!r   c                 f    | j                   }|j                  j                  | j                         y r   )r   r   rD   r  )r  r*  kwargsr   s       r   __exit__z_NumbaTypeHelper.__exit__  s    FF	t~~&r   c                 h    | j                   j                  j                  | j                  |g      }|S r   )r   r   r   r  )r  r(   rD  s      r   r   z_NumbaTypeHelper.typeof  s'    ffll00#G
r   N)__name__
__module____qualname____doc__r  r  r  r    r   r   r  r  {  s     'r   r  c                 R   fd}t         j                  j                  j                  j                  | |      \  }}j                  j                  |d      5 \  }	}
|	5  ||_        t        j                  |j                  d      }j                  j                  j                  j                  d||      d      5  t              5 }|j                  j                  j                  ||            }t!        j"                  j                  |      5 j                  j                  |j$                        } ||||       j'                  | j(                  |      }j                  j                  |j*                  d      5  j                  j-                  t         j.                         j1                          ddd       |j3                  j$                  |j4                  d       ddd       j                  j7                  |       ddd       ddd       | j8                  r||_        j                  j                  j                  j=                  j                  j?                              d      5  j                  jA                  ||jB                         ddd       |jE                  d       j                  j-                  |j4                  |       ddd       |
5  j                  j-                  t         j.                         ddd       ddd       j                  j                  j                  j?                              5  j                  jF                  j7                  j                  | |j4                         ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   3xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w)	z9
    Construct a new native list from a Python list.
    c                    | j                  |      }j                  j                  t        j                  j                  |      d      5  j                  j                  t        j                         j                          d d d        j                  j                  d||      }j                  j                  |d      5  j                  j                  t        j                         j                  j                  dd||       j                  j                  |       j                          d d d        j                  j                  |       y # 1 sw Y   xY w# 1 sw Y   1xY w)NFrH  r   ri   z(can't unbox heterogeneous list: %S != %S)r   r%   r   r   r   rE   rg  do_breakr&   r   rf  rD   )nthr  expected_typobjtypobjtype_mismatchr   errorptrr~  s        r   check_element_typez2_python_list_to_native.<locals>.check_element_type  s   G$YY		62   IIOOG,,h7MMO 		--dFOLYY}U;IIOOG,,h7GG!:
 GGNN6"MMO < 	
v%  <;s   ;E#A4E/#E,/E8TrH  r   >FN)r7  )$r   ru  allocate_exr-   r%   r   r   r   r#   r$   r   r&   r  r   r   list_getitemr   rw  ry  r   r   r!   rE   rg  r  setitemr]   rD   	reflectedr6  r   rG   object_set_private_datameminfo	set_dirtyr   )r   r(   r   r   listptrr  r  rq   r|  if_ok	if_not_okr*   r  r  r  r  r~  s     `  `          @r   _python_list_to_nativer    s   0 ##//		199c4PHB	
		2d		+/AyDI;;tyy!,D""199#8#8dD#I*. # 0 &a(C&)jj1E1Ec41P&QO **199d;t"#''"6"6sDJJ"G*3I "#G!<YY..vu.MIIOOG,<,<hG MMO N TZZeL < GGNN?3 )0& }}! ""199>>!))..2J#K9> # @//T\\B@ NN5!IIOODJJ0= @ IIOOG,,h7 C 
,J 
		199>>(3	4			QYYTZZ8 
5	4) NM <; )(0 0.@ @5 U@ YC 
,	+J 
5	4s   !P'A O8OAO	A4O;N70O>#O	!O)A*O8'O+:?O89
P+P.P2<P7O<OO	O	OOO(#O8+O50O88P	=PP	
PPP&c           
         j                   j                        }t        j                  j                  t        j
                        }t        j                  j                  j                  j                  |             }j                   j                        }j                  j                  t        j                  j                  |            5 \  }}|5  t        j                  j                  j                  j                  | |      }	||	_        | j                   r|	_        j                  j%                  |	j&                  |       ddd       |5  t)        | |||       ddd       ddd       fd}
t+        j                  j-                  |      j                  j-                  |      |
      S # 1 sw Y   rxY w# 1 sw Y   cxY w# 1 sw Y   gxY w)z
    Convert list *obj* to a native list.

    If list was previously unboxed, we reuse the existing native list
    to ensure consistency.
    Nc                  <     j                   j                         y r   r   object_reset_private_datar   r(   s   r   r   zunbox_list.<locals>.cleanup      	))#.r   r  )r   	list_sizer   r   r%   r  r?   r-   r   object_get_private_datar   r   r   ru  from_meminfor   r  r6  rE   r]   r  r	   rG   )r   r(   r   r   r  r  r   has_meminfor   r|  r   s    ``        r   
unbox_listr    sd    77S!D((G4E4EFH!!!))QYY-E-Ec-JKG ''
)
)#
.C	
		7..qyy#>	?#K''44QYY		3PSTDDI}}!IIOODJJ0  "3QgxH  
@/ qyy~~g. !		x 8&( ( [ Y 
@	?s=   GA7G
G G1GG	GG	GG(c           	         | j                   sy| j                  j                   rdj                  |       }t        |      t	        j
                  |j                  |j                  | |      }|j                  j                  |j                  d      5  |j                  }|j                  j                  |      }|j                  }|j                  j                  ||      }|j                  j                  d|t!        j"                  |j$                  d            }	|j                  j'                  |	      5 \  }
}|
5  t)        j*                  |j                  |      5 }|j-                  |j.                        }|j1                  |       |j3                  | j                  |      }|j                  j5                  ||j.                  |       ddd       t)        j*                  |j                  |      5 }|j                  j7                  ||j.                        }|j-                  |      }|j1                  |       |j3                  | j                  |      }|j                  j9                  ||       |j                  j;                  |       ddd       ddd       |5  |j                  j=                  |||d       t)        j*                  |j                  |      5 }|j-                  |j.                        }|j1                  |       |j3                  | j                  |      }|j                  j5                  ||j.                  |       ddd       ddd       ddd       |j?                  d       ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w# 1 sw Y   ^xY w# 1 sw Y   bxY w# 1 sw Y   yxY w)zD
    Reflect the native list's contents into the Python object.
    Nz2cannot reflect element of reflected container: {}
FrH  z>=r   ) r  r   format	TypeErrorr   ru  r-   r%   r   dirtyr6  r   r  r   subr&   r   r#   r$   r   r   rw  rx  ry  rz  r   r{  r   list_appendrD   list_setslicer  )r   r   r   r   r|  r(   r   new_sizediff	diff_gt_0if_grow	if_shrinkr~  rY  r  r   s                   r   reflect_listr    s   
 ==
yyCJJ3On		199c3?D	
		4::e		4kkww  %99yy}}Xt,II))$*,++dii*CE	YYy)-Agy&&qyy$74<<

3D%%d+eeCIIt4GGG((djj'B	 8 &&qyy$74))--djj9C<<,D%%d+eeCIIt4GGG''W5GGNN7+ 8   %%c8T4@&&qyy(;t<<

3D%%d+eeCIIt4GGG((djj'B	 <	 % *: 	uI 
5	4 87 87 ( <;	 % *) 
5	4s   B&O9O?!N! A0N	(N!8BN	N!
O&?N:%A0N.	N:O%ONN!NN!!N+&O.N73N::O?OO	OOc                 	   t         j                  j                  |j                  |j                  | |      \  }}|j                  j                  |d      5 \  }}	|5  t        j                  |j                  t        j                  |j                  j                  d            }
|j                  j                  |      5 }|j                  }|j                  j                  |      }|j                  j                  |
      }|j                  j                  t        j                   |j                  |      d      5 \  }}|5  |j                  j#                  ||
       ddd       |5  |j                  j%                  d||      }|j                  j'                  |d      5  |j                  j#                  t        j(                  |       |j                  j+                  dd       |j-                          ddd       ddd       ddd       |j/                  | j0                  |      }|j                  j'                  |j2                  d      5  |j                  j#                  t        j(                  |       ddd       |j5                  |j                  |j                  d       ddd       | j6                  r||_        |j                  j'                  |j                  j;                  |j                  j                  |            d      5  |j                  j=                  ||j>                         ddd       |jA                  d       |j                  j#                  |j                  |       ddd       |	5  |j                  j#                  t        j(                  |       ddd       ddd       |j                  j'                  |j                  j                  |            5  |j                  jB                  jE                  |j                  | |j                         ddd       y# 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   XxY w# 1 sw Y   ]xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   MxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w)	z7
    Construct a new native set from a Python set.
    TrH  NFr   ri   zcan't unbox heterogeneous set)	do_resize)#r   SetInstancer  r-   r%   r   r   r   r   r#   r   pyobjset_iterater]   get_typerG   r   rE   r&   r   rg  rn   r  r   r   r!   	add_pyapir  r6  r   r  r  r  r   rD   )r   r(   r   r   setptrr  rq   instr  r  	typobjptrr~  r  r  r  if_firstif_not_firstr  r  s                      r   _python_set_to_nativer  A  si   
 !!--aiiCNHB	
		2d		+/Ay11!))24++aggmmT2RTI $$S)T**))'2"#))..";YY&&OOAII?  ' "%=h!			: " &()		(=(=dF>M)OYY..}U.KIIOOG,<,<hGGG223D3RT MMO	 L	 &"& G4YY&&vu&EIIOOG$4$4h? FqwwF9 *< }}!""199>>!))..2J#K*/ # 1//T\\B1 NN5!IIOODJJ/U X IIOOG,,h7 [ 
,b 
		199>>(3	4			QYYTZZ8 
5	4E " LK	 &" "( FE5 *)B1 1M UX Y[ 
,	+b 
5	4s   R6A$RA>R?Q)	Q"
Q)	,;Q'AQ>QQ)	AR+Q6	0R4A*R'R?R
R6+R*9R6=<SQQ)	QQQ&!Q)	)Q3.R6R ;RRRRRR'	"R6*R3	/R66R?Sc           
         j                   j                        }t        j                  j                  t        j
                        }t        j                  j                  j                  j                  |             }j                   j                        }j                  j                  t        j                  j                  |            5 \  }}|5  t        j                  j                  j                  j                  | |      }	| j                  r|	_        j                  j#                  |	j$                  |       ddd       |5  t'        | |||       ddd       ddd       fd}
t)        j                  j+                  |      j                  j+                  |      |
      S # 1 sw Y   rxY w# 1 sw Y   cxY w# 1 sw Y   gxY w)z
    Convert set *obj* to a native set.

    If set was previously unboxed, we reuse the existing native set
    to ensure consistency.
    Nc                  <     j                   j                         y r   r  r  s   r   r   zunbox_set.<locals>.cleanup  r  r   r  )r   set_sizer   r   r%   r  r?   r-   r   r  r   r   r   r  r  r  r6  rE   r]   r  r	   rG   )r   r(   r   r   r  r  r   r  r   r  r   s    ``        r   	unbox_setr  |  s\    77C D((G4E4EFH  AII,D,DS,IJF ''
)
)#
.C	
		7..qyy#>	?#K%%22199aiicRD}}!IIOODJJ/  !#sAtVXF  
@/ qyy~~f- !		x 8&( ( [ Y 
@	?s=   GA0G 
GG*G G		GG	GG!c           	         |j                   }|j                  j                  |      }t        j                  |j
                  |      }|j
                  j                  |d      5  t        j                  |j
                  t        j                  |j                  d            }|j                         5 }|j
                  j                  |      }|j                  j                  }	|j                  j                   j#                  |j
                  | j$                  |	       |j'                  | j$                  |	      }
|j                  j)                  |||
       |j
                  j+                  |t        j                  |j                  d            }|j
                  j-                  ||       ddd       ddd       ||fS # 1 sw Y   xY w# 1 sw Y   ||fS xY w)z9
    Create a Python list from a native set's items.
    TrH  r   r   N)usedr   rv  r   r   r%   r   r   r   r#   r$   _iteraterG   entrykeyr-   r   r7  r   r   r{  r   rE   )r   payloadr   r   r   rq   ry  r~  rX  rY  r  s              r   _native_set_to_python_listr    sV    \\Fggv&G			QYY	0B	
		2d		+))!))*,++fkk1*EG4		u%A::>>DIIMM  CIIt<eeCIIt,GGG  !W5		aQVVQ!78AIIOOAu%   
, w;   
, w;s&   %AG4C<G0GG		GGc                    t        j                  |j                  |j                  | |      }|j                  }t        j                  |j                  |      }|j                  j                  t        j                  |j                  |            5 \  }}|5  |j                  j                  |       ddd       |5  |j                  }t        | ||      \  }	}
|j                  j                  |	d      5  |j                  j                  |
      }|j                  j                  |
       |j                  j!                  ||       ddd       ddd       ddd       |j                  j"                  j                  |j                  | |       |j                  j%                  |      S # 1 sw Y   xY w# 1 sw Y   qxY w# 1 sw Y   uxY w# 1 sw Y   yxY w)z3
    Convert native set *val* to a set object.
    NTrH  )r   r  r-   r%   r6  r   r   r   r   r   r7  r  r  r   set_newrD   rE   r   rG   )r   r   r   r  r(   rD  r}  r   r  rq   r   s              r   box_setr    sW   
 aiiC=D
++C

#
#AIIs
3C	
		7..qyy#>	?CZJPY GGNN3	  llG4S'1EKB""2d"3ggoog.w'		S) 4	  
@" IIMMC-99>>## Z 43	 Y 
@	?sU   GF/4
G>:G8AF;GG/F8	4G;G GG	GGc                 h   | j                   syt        j                  |j                  |j                  | |      }|j
                  }|j                  j                  |j                  d      5  |j                  }|j                  j                  |       t        | ||      \  }}|j                  j                  |d      5  |j                  j                  ||       |j                  j                  |       ddd       |j                  d       ddd       y# 1 sw Y   #xY w# 1 sw Y   yxY w)zC
    Reflect the native set's contents into the Python object.
    NFrH  T)r  r   r  r-   r%   r  r   r  r6  r   	set_clearr  
set_updaterD   r  )r   r   r   r  r  r(   rq   r   s           r   reflect_setr    s    
 ==aiiC=DllG	
		7==		7kk	# 1gqAGYYr$/GGsG,GGNN7# 0
 	u 
8	7 0/ 
8	7s%   -AD(8D:D(D%	!D((D1c                 d    |j                   j                  || |j                  j                        S r   )r   from_native_generatorr   env_ptrr   s      r   box_generatorr    s%    77((c1==3H3HIIr   c                 :    |j                   j                  ||       S r   )r   to_native_generatorr-  s      r   unbox_generatorr    s    77&&sC00r   c                     t        j                  | j                        }|j                  j	                  |j                  j                  |            S r   r   r2  r   r   r   r   r   r   r   r:  s       r   	box_dtyper    :    %%cii0H77qww77ABBr   c                 H    t        |j                  j                               S r   ry   r   s      r   unbox_dtyper         qyy00233r   c                     t        j                  | j                        }|j                  j	                  |j                  j                  |            S r   r  r  s       r   box_number_classr    r  r   c                 H    t        |j                  j                               S r   ry   r   s      r   unbox_number_classr  
  r  r   c                     |S r   r  r   s      r   box_pyobjectr    s	     Jr   c                     t        |      S r   r	   r-  s      r   unbox_pyobjectr         sr   c                 b   | j                   t        |       |j                  j                  |       }t	        j
                  |j                  t        j                  |d       d      }|j                  j                  | j                         }|j                  j                  |      }t	        j                  |j                  t	        j                  |j                  |            5  |j                  j                  ||f      }|j                  j                  |       t	        j                  |j                  t	        j                  |j                  |            5  |j                  j!                  |      }|j                  j                  |       |j                  j#                  |j                  j%                  ||      |       d d d        d d d        t'        |j                  j)                  |      |j                  j+                               S # 1 sw Y   OxY w# 1 sw Y   SxY w)Nfnptr)namer    )get_pointerNotImplementedErrorr-   get_function_pointer_typer   r   r%   r   r#   r   r   r   r   r   r   rD   long_as_voidptrrE   r   r	   rG   r'   )	r   r(   r   ptrtyr   serr   intobjr   s	            r   unbox_funcptrr    s   
!#&& II//4E

#
#AII$&KKt$<)02C ''
"
"3??
3C''%%c*K			199"..qyy+F
H..{SFC	{#qyy&22199fEG''))&1CGGNN6"IIOOAII--c593?	G	
H qyy~~c*QWW5H5H5JKKG G	
H 
Hs&   'A7H%A-HH%H"	H%%H.c                     |j                   j                  | j                         |j                  j	                  |dg      |j
                        }|S )Nr   )r   )r   from_native_valuegetr%   rU  r   )r   r   r   outs       r   box_deferredr  1  sG    
''
#
#CGGI$%II$;$;C!$E01 $ ?C Jr   c                 6   |j                   j                  | j                         |      }|j                  j                  |    }|j                  |j                  |j                         |j                        }t        ||j                  |j                        S )Nr  )r   to_native_valuer
  r-   data_model_managersetr%   make_uninitializedr]   r	   r!   r   )r   r(   r   native_valuemodelrD  s         r   unbox_deferredr  9  sw    77**3779c:LII((-E
))AIIu779<;M;M
NCs\%:%:+335 5r   c                     t        |      S r   r  r-  s      r   unbox_dispatcherr  B  r  r   c                 <    |j                   j                  |       |S r   )r   r7  r   s      r   r  r  H  s    GGNN3Jr   c                     |j                   j                  ddj                  |              |j                  j	                  |       }t        |t        j                        S )Nri   zcan't unbox {!r} typer    )r   rn   r  r-   get_constant_nullr	   r   rg  )r   r(   r   rD  s       r   unbox_unsupportedr  N  sM    GG,299#>@
))
%
%c
*CsW%5%566r   c                 ~    d| d}|j                   j                  d|       |j                   j                         }|S )Nzcannot convert native z to Python objectri   )r   rn   get_null_object)r   r   r   r   rD  s        r   box_unsupportedr  U  s6    9<
>CGG,c2
''
!
!
#CJr   c                     | j                   }|j                  j                  |j                  j                  |            S r   )r  r   r   r   )r   r   r   retvals       r   box_literalr   \  s3     F77qww77?@@r   c                 8    |j                   j                  |      S r   )r   nrt_meminfo_as_pyobjectr   s      r   box_meminfo_pointerr#  e  s    77**3//r   c                     |j                   j                  |      }t        j                  |j                  |      }t        ||      S r=   )r   nrt_meminfo_from_pyobjectr   r   r%   r	   )r   r(   r   rD  erroreds        r   unbox_meminfo_pointerr'  j  s7    
''
+
+C
0Cooaii-GsW--r   c                 h    t        |j                  j                         t        j                        S r=   )r	   r-   rz   r   r  r   s      r   unbox_typerefr)  p  s"    qyy002W=N=NOOr   c                     t        | ||      S r   )r  r   s      r   box_LiteralStrKeyDictr+  u  s    3Q''r   c           
      b  	
 t        j                  j                  t         j                        g fd		fdt	               5 fd t        j
                  |       j                  j                        |_         |d      t        j                  j                        5           ddd        d      }t        j                  j                  |      5           ddd       t        dj                  t        j                  |      j                          d      }t        j                  j                  |      5           ddd        |d      }t        j                  j                  |      5           ddd       t        dj                  t        j                  |      j                         j                  j                  j                  j                  d      }j                   j#                  |      }j%                  |       t        j                  j                  |      5           ddd        |d	      
t        j                  j                  
      5           ddd        |d
      t        j                  j                        5           ddd       
f	d} |d        |d        |d        	        ddd       t'        j)                         j                  j+                              S # 1 sw Y   xY w# 1 sw Y   ^xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)ar  
    The bit_generator instance has a `.ctypes` attr which is a namedtuple
    with the following members (types):
    * state_address (Python int)
    * state (ctypes.c_void_p)
    * next_uint64 (ctypes.CFunctionType instance)
    * next_uint32 (ctypes.CFunctionType instance)
    * next_double (ctypes.CFunctionType instance)
    * bit_generator (ctypes.c_void_p)
    c                  J    D ]  } j                   j                  |         y r   )r   rD   )_refr   
extra_refss    r   clear_extra_refsz9unbox_numpy_random_bitgenerator.<locals>.clear_extra_refs  s    DGGNN4  r   c                  h     j                   j                  t        j                                  y r   )r%   rE   r   rg  )r   r0  rm  s   r   handle_failurez7unbox_numpy_random_bitgenerator.<locals>.handle_failure  s!    			((,7r   c                 b    j                   j                  | |      }j                  |       |S r   )r   r   ri  )r(   attrattr_objr   r/  s      r   object_getattr_safelyz>unbox_numpy_random_bitgenerator.<locals>.object_getattr_safely  s,    ww44S$?Hh'Or   ctypesNstate_addressstater]   r.   c_void_pc                   	 j                   j                  |       }	j                  |       t        j                  j
                  |      5   
        d d d        j                   j                  |g      }t        j                  j
                  |      5   
        d d d        j                   j                  |      } |d      }t        j                  j
                  |      5   
        d d d        t        d|  j                  t        j                  |      j                         y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w)Nr]   fnptr_)r   r   ri  r   early_exit_if_nullr%   
tuple_packr   setattrr   r   r   r]   )r  interface_next_fnr*  interface_next_fn_castedinterface_next_fn_casted_valuer   ct_castct_voidptr_tyctypes_bindingr/  r2  r6  stack
struct_ptrs        r   wire_in_fnptrsz7unbox_numpy_random_bitgenerator.<locals>.wire_in_fnptrs  s(    ! = =!& /0++AIIu>OP  Q
 77%%'8-&HID++AIIudC  D ()ww||GT'B$ .C('.3*++AIIu>\]  ^ J&GGEKK)GHNNP) QP DC ^]s$   D=E	4E=E	EEnext_doublenext_uint64next_uint32r    )r   r   r%   r  r   create_struct_proxyr-   r6  r=  r?  r   r   r   r]   r  r  r   r  ri  r	   ro   rG   )r   r(   r   interface_state_addressinterface_stateinterface_state_valuectypes_namectypes_modulerH  r0  rC  rD  rE  r/  r2  rm  r6  rF  rG  s     `      @@@@@@@@@@r   unbox_numpy_random_bitgeneratorrR  {  s    ,,QYY8I8IJLJ! 
	
 6W005aiiK

 /sH=''		5.I J #8O#-''		5:QR S 	
O%<=CC	E 0H''		5/J K !6W!&''		5:OP QGG%'',u	. ii33AII4D4DhO55kB-(''		5-H I (v>''		5'B C .mZH''		5-H I	P 	P< 	}%}%}%{ 
~ z++-		|8TUUg JI SR KJ
 QP  IH CB IHo 
s   A(N%;M2N%5M=A'N%$M&,2N%M3&B:N% N (2N%N"2N%N4N%M	N%M#	N%&M0	+N%3M=	8N% N
	N%N	N%N"	N%%N.bit_generatorc                 Z   t        j                  |j                  t         j                        }t	               5 } t        j
                  |       |j                  |j                        }|j                  j                  |d      }t        j                  |j                  ||      5  |j                  j                  t         j                  |       ddd       |j                  t        |      j                  }||_        ||_        t        j"                  d      }|j                  j%                  ||      |_        |j                  j)                  |       ddd       t+        j-                         |j                  j/                  |            S # 1 sw Y   xY w# 1 sw Y   IxY w)a  
    Here we're creating a NumPyRandomGeneratorType StructModel with following fields:
    * ('bit_generator', _bit_gen_type): The unboxed BitGenerator associated with
                                        this Generator object instance.
    * ('parent', types.pyobject): Pointer to the original Generator PyObject.
    * ('meminfo', types.MemInfoPointer(types.voidptr)): The information about the memory
        stored at the pointer (to the original Generator PyObject). This is useful for
        keeping track of reference counts within the Python runtime. Helps prevent cases
        where deletion happens in Python runtime without NRT being awareness of it. 
    rS  Nr    )r   r   r%   r  r   rL  r-   r   r   r=  rE   rg  r   _bit_gen_typer]   rS  r6  	voidptr_tnrt_meminfo_new_from_pyobjectr  rD   r	   ro   rG   )	r   r(   r   rm  rF  rG  bit_gen_instunboxedNULLs	            r   unbox_numpy_random_generatorr[    s3    ,,QYY8I8IJL	5W005aiiK
ww44S/J''		5,GIIOOG,,l; H''-6<<#*
 
  &WWBB


 	
|$ 
  z++-		|8TUU HG 
s%   A.F!'+FBF!F	F!!F*c                 v   |j                   j                  |j                  | |      }|j                  }t	        j
                  |j                  |      }|j                  j                  |       |j                   j                  j                  |j                  | |       |j                  j                  |      S r   )r-   r   r%   r6  r   r   r   r7  r   rD   rG   )r   r   r   r  r(   rD  s         r   box_numpy_random_generatorr]    s~    99  C5D
++C

#
#AIIs
3CGGNN3IIMMC-99>>#r   N)r  llvmliter   
numba.corer   r   numba.core.pythonapir   r   r   r	   numba.core.errorsr
   r   numba.core.typing.typeofr   r   r  r   r   numba.npr   
contextlibr   r   Booleanr   r+   IntegerLiteralBooleanLiteralr0   Integerr;   rK   FloatrS   rY   Complexrg   rt   NoneTyperw   EllipsisTyper{   
NPDatetimer   r   NPTimedeltar   r   
RawPointerr   
EnumMemberr   r   UndefVarr   Recordr   r   UnicodeCharSeqr   r   Bytesr   CharSeqr   r   Optionalr  r  	SliceTyper  SliceLiteralr+  StringLiteralr.  Arrayr=  BufferrF  rQ  TupleUniTuplerZ  
NamedTupleNamedUniTupler]  	BaseTuplers  Listr  objectr  r  r  r  r  Setr  r  r  r  	Generatorr  r  DTyper  r  NumberClassr  r  PyObjectObjectr  r  ExternalFunctionPointerr  DeferredTyper  r  
Dispatcherr  r  r  Literalr   MemInfoPointerr#  r'  TypeRefr)  LiteralStrKeyDictr+  NumPyRandomBitGeneratorTyperR  rU  NumPyRandomGeneratorTyper[  r]  r  r   r   <module>r     se    % A A C 4 ) " 0 U]]' ' u}}< < UU(  (
 U]]3 3 u}}7 7 U[[, , u{{
< 
< U]]	6 	6 u}}: :. U^^  u~~u4  4 U: : u< <
 U; ; u< <
 U$ $ U= = u& & U^^  U\\H H u||
@ 
@ UC C2 u9 9: U[[  U]]> >, u}}9 96 U^^	 	 u~~( (B u
E 
E U 2 u4 4 U[[   u||( (2 u{{,@ ,@^ U[[U^^   UU	  	 u.> .>b UZZ B#v #LC9L uzz#( #(L 	/ /d89v uyy"( "(J, UYY 8 	 8 U__J J u1 1 U[[C C u{{4 4 UC C u4 4 U^^U\\   u~~u||   u$$%L &L, U  u5 5 u 
 U 
7 U]]A A U0 0 u. .
 u}}P P U( (
 u(()vV *vVp 211/Bu%%&V 'V@ U##$ %r   