numbox 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numbox/__init__.py +1 -1
- numbox/core/any_type.py +36 -8
- {numbox-0.1.3.dist-info → numbox-0.1.4.dist-info}/METADATA +1 -1
- numbox-0.1.4.dist-info/RECORD +13 -0
- numbox/core/declare_func.py +0 -2270
- numbox-0.1.3.dist-info/RECORD +0 -14
- {numbox-0.1.3.dist-info → numbox-0.1.4.dist-info}/LICENSE +0 -0
- {numbox-0.1.3.dist-info → numbox-0.1.4.dist-info}/WHEEL +0 -0
- {numbox-0.1.3.dist-info → numbox-0.1.4.dist-info}/top_level.txt +0 -0
numbox/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.1.
|
|
1
|
+
__version__ = '0.1.4'
|
numbox/core/any_type.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
from inspect import getmodule, getsource
|
|
1
2
|
from numba import njit
|
|
2
3
|
from numba.core.errors import NumbaError
|
|
3
|
-
from numba.core.
|
|
4
|
+
from numba.core.itanium_mangler import mangle_type_or_value
|
|
5
|
+
from numba.core.types import StructRef, Type
|
|
4
6
|
from numba.experimental.structref import define_boxing, new, register, StructRefProxy
|
|
5
7
|
from numba.extending import overload, overload_method
|
|
6
8
|
|
|
@@ -25,7 +27,10 @@ class _Content:
|
|
|
25
27
|
pass
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
default_jit_options = {'cache': True}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@overload(_Content, strict=False, jit_options=default_jit_options)
|
|
29
34
|
def ol_content(x_ty):
|
|
30
35
|
x_ty = prune_type(x_ty)
|
|
31
36
|
content_type = ContentTypeClass([("x", x_ty)])
|
|
@@ -49,11 +54,11 @@ class Any(StructRefProxy):
|
|
|
49
54
|
def __new__(cls, x):
|
|
50
55
|
raise NotImplementedError(deleted_any_ctor_error)
|
|
51
56
|
|
|
52
|
-
@njit
|
|
57
|
+
@njit(cache=True)
|
|
53
58
|
def get_as(self, ty):
|
|
54
59
|
return self.get_as(ty)
|
|
55
60
|
|
|
56
|
-
@njit
|
|
61
|
+
@njit(cache=True)
|
|
57
62
|
def reset(self, val):
|
|
58
63
|
return self.reset(val)
|
|
59
64
|
|
|
@@ -67,22 +72,45 @@ define_boxing(AnyTypeClass, Any)
|
|
|
67
72
|
AnyType = AnyTypeClass([("p", ErasedType)])
|
|
68
73
|
|
|
69
74
|
|
|
70
|
-
@overload_method(AnyTypeClass, "get_as", strict=False)
|
|
75
|
+
@overload_method(AnyTypeClass, "get_as", strict=False, jit_options=default_jit_options)
|
|
71
76
|
def ol_get_as(self_class, ty_class):
|
|
72
77
|
def _(self, ty):
|
|
73
78
|
return deref(self.p, ty)
|
|
74
79
|
return _
|
|
75
80
|
|
|
76
81
|
|
|
77
|
-
@overload_method(AnyTypeClass, "reset", strict=False)
|
|
82
|
+
@overload_method(AnyTypeClass, "reset", strict=False, jit_options=default_jit_options)
|
|
78
83
|
def ol_reset(self_class, x_class):
|
|
79
84
|
def _(self, x):
|
|
80
85
|
self.p = cast(_Content(x), ErasedType)
|
|
81
86
|
return _
|
|
82
87
|
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
def make_any(x):
|
|
89
|
+
def make_any_prototype(x):
|
|
86
90
|
any = new(AnyType)
|
|
87
91
|
any.p = cast(_Content(x), ErasedType)
|
|
88
92
|
return any
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
make_any = njit(**default_jit_options)(make_any_prototype)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def make_any_maker(arg_type=None, jit_options=None):
|
|
99
|
+
if arg_type is None:
|
|
100
|
+
return make_any
|
|
101
|
+
if not isinstance(arg_type, Type):
|
|
102
|
+
raise TypeError(f"Expected numba type, got {arg_type}")
|
|
103
|
+
jit_options = {**default_jit_options, **(jit_options or {})}
|
|
104
|
+
sig = AnyType(arg_type)
|
|
105
|
+
custom_make_any_name = f"make_any_{mangle_type_or_value(arg_type)}"
|
|
106
|
+
source_code = getsource(make_any_prototype)
|
|
107
|
+
source_code = source_code.replace('make_any_prototype', custom_make_any_name)
|
|
108
|
+
code_txt = f"""
|
|
109
|
+
@njit(sig, **jit_options)
|
|
110
|
+
{source_code}
|
|
111
|
+
"""
|
|
112
|
+
code = compile(code_txt, __file__, mode='exec')
|
|
113
|
+
ns = {**getmodule(make_any).__dict__, **{'sig': sig, 'jit_options': jit_options}}
|
|
114
|
+
exec(code, ns)
|
|
115
|
+
custom_make_any = ns[custom_make_any_name]
|
|
116
|
+
return custom_make_any
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
numbox/__init__.py,sha256=aBEbDvx4LMg8A1TJJR6dEHu8rQODVin528hLS_EDvuA,22
|
|
2
|
+
numbox/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
numbox/core/any_type.py,sha256=qi5vZD5-s-3ksTORes4rCF2t7H6jpz3whsKNxc4Oyq8,2843
|
|
4
|
+
numbox/core/meminfo.py,sha256=-b7wlCRyqOZjvKjEuwNwzqE4XvnEWxu3I2k4DEP3Cqk,1755
|
|
5
|
+
numbox/core/proxy.py,sha256=kGYlEdLK40lxxu56e_S32s9YuQ6AuQnFegt5uQrUw5w,3889
|
|
6
|
+
numbox/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
numbox/utils/highlevel.py,sha256=hAmF2y2ayPJT0qpwHrGDt09R4-6Ts9sTkCTh-8FTIUU,319
|
|
8
|
+
numbox/utils/lowlevel.py,sha256=6CRfFbMeBZGM7hqPAQzyClzU_e_IsNpqONJknFWGzJM,1405
|
|
9
|
+
numbox-0.1.4.dist-info/LICENSE,sha256=YYgNvjH_p6-1NsdrIqGJnr1GUbZzA_8DxsP6vVfM6nY,1446
|
|
10
|
+
numbox-0.1.4.dist-info/METADATA,sha256=kx51gPJjDouxGwrmuwfijb72klqlmQ5jC8IzVg1suTw,2271
|
|
11
|
+
numbox-0.1.4.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
12
|
+
numbox-0.1.4.dist-info/top_level.txt,sha256=A67jOkfqidCSYYm6ifjN_WZyIiR1B27fjxv6nNbPvjc,7
|
|
13
|
+
numbox-0.1.4.dist-info/RECORD,,
|