1import struct 2 3import numpy as np 4from numba.core import utils 5 6from .abstract import * 7from .containers import * 8from .functions import * 9from .iterators import * 10from .misc import * 11from .npytypes import * 12from .scalars import * 13from .function_type import * 14 15# Short names 16 17pyobject = PyObject('pyobject') 18ffi_forced_object = Opaque('ffi_forced_object') 19ffi = Opaque('ffi') 20none = NoneType('none') 21ellipsis = EllipsisType('...') 22Any = Phantom('any') 23undefined = Undefined('undefined') 24py2_string_type = Opaque('str') 25unicode_type = UnicodeType('unicode_type') 26string = unicode_type 27unknown = Dummy('unknown') 28 29code_type = Opaque('code') 30pyfunc_type = Opaque('pyfunc') 31 32# No operation is defined on voidptr 33# Can only pass it around 34voidptr = RawPointer('void*') 35 36boolean = bool_ = Boolean('bool') 37 38byte = uint8 = Integer('uint8') 39uint16 = Integer('uint16') 40uint32 = Integer('uint32') 41uint64 = Integer('uint64') 42 43int8 = Integer('int8') 44int16 = Integer('int16') 45int32 = Integer('int32') 46int64 = Integer('int64') 47intp = int32 if utils.MACHINE_BITS == 32 else int64 48uintp = uint32 if utils.MACHINE_BITS == 32 else uint64 49intc = int32 if struct.calcsize('i') == 4 else int64 50uintc = uint32 if struct.calcsize('i') == 4 else uint64 51 52float32 = Float('float32') 53float64 = Float('float64') 54 55complex64 = Complex('complex64', float32) 56complex128 = Complex('complex128', float64) 57 58range_iter32_type = RangeIteratorType(int32) 59range_iter64_type = RangeIteratorType(int64) 60unsigned_range_iter64_type = RangeIteratorType(uint64) 61range_state32_type = RangeType(int32) 62range_state64_type = RangeType(int64) 63unsigned_range_state64_type = RangeType(uint64) 64 65slice2_type = SliceType('slice<a:b>', 2) 66slice3_type = SliceType('slice<a:b:c>', 3) 67 68signed_domain = frozenset([int8, int16, int32, int64]) 69unsigned_domain = frozenset([uint8, uint16, uint32, uint64]) 70integer_domain = signed_domain | unsigned_domain 71real_domain = frozenset([float32, float64]) 72complex_domain = frozenset([complex64, complex128]) 73number_domain = real_domain | integer_domain | complex_domain 74 75# Aliases to NumPy type names 76 77b1 = bool_ 78i1 = int8 79i2 = int16 80i4 = int32 81i8 = int64 82u1 = uint8 83u2 = uint16 84u4 = uint32 85u8 = uint64 86 87f4 = float32 88f8 = float64 89 90c8 = complex64 91c16 = complex128 92 93float_ = float32 94double = float64 95void = none 96 97_make_signed = lambda x: globals()["int%d" % (np.dtype(x).itemsize * 8)] 98_make_unsigned = lambda x: globals()["uint%d" % (np.dtype(x).itemsize * 8)] 99 100char = _make_signed(np.byte) 101uchar = byte = _make_unsigned(np.byte) 102short = _make_signed(np.short) 103ushort = _make_unsigned(np.short) 104int_ = _make_signed(np.int_) 105uint = _make_unsigned(np.int_) 106intc = _make_signed(np.intc) # C-compat int 107uintc = _make_unsigned(np.uintc) # C-compat uint 108long_ = _make_signed(np.long) 109ulong = _make_unsigned(np.long) 110longlong = _make_signed(np.longlong) 111ulonglong = _make_unsigned(np.longlong) 112 113# optional types 114optional = Optional 115 116 117deferred_type = DeferredType 118 119__all__ = ''' 120int8 121int16 122int32 123int64 124uint8 125uint16 126uint32 127uint64 128intp 129uintp 130intc 131uintc 132boolean 133float32 134float64 135complex64 136complex128 137bool_ 138byte 139char 140uchar 141short 142ushort 143int_ 144uint 145long_ 146ulong 147longlong 148ulonglong 149float_ 150double 151void 152none 153b1 154i1 155i2 156i4 157i8 158u1 159u2 160u4 161u8 162f4 163f8 164c8 165c16 166optional 167ffi_forced_object 168ffi 169deferred_type 170'''.split() 171