bool-hybrid-array 9.11.8__py3-none-any.whl → 9.11.9__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.
- bool_hybrid_array/__init__.py +1 -1
- bool_hybrid_array/core.c +17255 -9262
- bool_hybrid_array/core.cp314-win_amd64.pyd +0 -0
- bool_hybrid_array/core.py +220 -4
- {bool_hybrid_array-9.11.8.dist-info → bool_hybrid_array-9.11.9.dist-info}/METADATA +2 -1
- bool_hybrid_array-9.11.9.dist-info/RECORD +13 -0
- bool_hybrid_array-9.11.8.dist-info/RECORD +0 -12
- {bool_hybrid_array-9.11.8.dist-info → bool_hybrid_array-9.11.9.dist-info}/WHEEL +0 -0
- {bool_hybrid_array-9.11.8.dist-info → bool_hybrid_array-9.11.9.dist-info}/licenses/LICENSE +0 -0
- {bool_hybrid_array-9.11.8.dist-info → bool_hybrid_array-9.11.9.dist-info}/top_level.txt +0 -0
|
Binary file
|
bool_hybrid_array/core.py
CHANGED
|
@@ -14,6 +14,11 @@ import operator,ctypes,gc,abc,types
|
|
|
14
14
|
from functools import lru_cache
|
|
15
15
|
from typing import _GenericAlias
|
|
16
16
|
from typing import Callable, Union, Sequence, MutableSequence, Any, overload, Sized
|
|
17
|
+
from ctypes import *
|
|
18
|
+
try:
|
|
19
|
+
import msvcrt
|
|
20
|
+
except ImportError:
|
|
21
|
+
pass
|
|
17
22
|
hybrid_array_cache:list[tuple[Any]] = []
|
|
18
23
|
try:
|
|
19
24
|
msvcrt = ctypes.CDLL('msvcrt.dll')
|
|
@@ -766,7 +771,7 @@ class ProtectedBuiltinsDict(dict,metaclass=ResurrectMeta):# type: ignore
|
|
|
766
771
|
"TruesArray", "FalsesArray", "ProtectedBuiltinsDict", "builtins",
|
|
767
772
|
"__builtins__", "__dict__","ResurrectMeta","math",
|
|
768
773
|
"np","protected_names","BHA_Function",
|
|
769
|
-
"__class__","Ask_BHA","Create_BHA","Ask_arr","numba_opt","bool_hybrid_array"),
|
|
774
|
+
"__class__","Ask_BHA","Create_BHA","Ask_arr","numba_opt","bool_hybrid_array","BHA_Queue","cin","cout","endl"),
|
|
770
775
|
name = 'builtins', **kwargs):
|
|
771
776
|
super().__init__(*args, **kwargs)
|
|
772
777
|
if name == 'builtins':
|
|
@@ -878,12 +883,10 @@ class BHA_Queue:
|
|
|
878
883
|
self.a.push(v)
|
|
879
884
|
def dequeue(self):
|
|
880
885
|
if self.b:
|
|
881
|
-
print("正常执行")
|
|
882
886
|
return self.b.pop()
|
|
883
887
|
elif self.a:
|
|
884
|
-
tmp = self.a
|
|
888
|
+
tmp = BoolHybridArr(reversed(self.a))
|
|
885
889
|
self.b.split_index,self.b.large,self.b.small,self.b.is_sparse = tmp.split_index,tmp.large,tmp.small,tmp.is_sparse
|
|
886
|
-
print(f"self.b:{self.b}")
|
|
887
890
|
self.a.clear()
|
|
888
891
|
return self.dequeue()
|
|
889
892
|
else:
|
|
@@ -935,6 +938,215 @@ def numba_opt():
|
|
|
935
938
|
])
|
|
936
939
|
bisect.bisect_left = numba.njit(sig, cache=True)(bisect.bisect_left)
|
|
937
940
|
bisect.bisect_right = numba.njit(sig, cache=True)(bisect.bisect_right)
|
|
941
|
+
class InPutObject:
|
|
942
|
+
def __init__(self):
|
|
943
|
+
self._stdout = sys.stdout
|
|
944
|
+
if sys.platform == "win32":
|
|
945
|
+
self._get_char = lambda: ord(msvcrt.getche())
|
|
946
|
+
self.backch = " \b"
|
|
947
|
+
else:
|
|
948
|
+
libc_path = "libc.so.6" if sys.platform == "linux" else "libSystem.B.dylib"
|
|
949
|
+
self.libc = ctypes.cdll.LoadLibrary(libc_path)
|
|
950
|
+
self._get_char = lambda:(c:=ord(self.libc.getchar()),
|
|
951
|
+
self._stdout.write(chr(c)),self._stdout.flush())[0]
|
|
952
|
+
self.backch = "\b \b"
|
|
953
|
+
self._whitespace = {ord('\n'), ord('\t'), ord(' '), 0, ord("\r")}
|
|
954
|
+
self.getchar = self._get_char
|
|
955
|
+
self._buf = []
|
|
956
|
+
|
|
957
|
+
def _read_char(self):
|
|
958
|
+
while True:
|
|
959
|
+
if self._buf:char = self._buf.pop(0)
|
|
960
|
+
else:char = self._get_char()
|
|
961
|
+
if char in self._whitespace or char == -1:
|
|
962
|
+
continue
|
|
963
|
+
return char
|
|
964
|
+
|
|
965
|
+
def _parse_int(self):
|
|
966
|
+
chars = []
|
|
967
|
+
while True:
|
|
968
|
+
if self._buf:
|
|
969
|
+
char = self._buf.pop(0)
|
|
970
|
+
else:
|
|
971
|
+
char = self._get_char()
|
|
972
|
+
if char in self._whitespace or char == -1:
|
|
973
|
+
break
|
|
974
|
+
if char == 8:
|
|
975
|
+
sys.stdout.write(self.backch)
|
|
976
|
+
sys.stdout.flush()
|
|
977
|
+
try:
|
|
978
|
+
chars.pop()
|
|
979
|
+
except:
|
|
980
|
+
pass
|
|
981
|
+
continue
|
|
982
|
+
elif chr(char) not in '+-0123456789':
|
|
983
|
+
self._buf.append(char)
|
|
984
|
+
break
|
|
985
|
+
else:
|
|
986
|
+
chars.append(chr(char))
|
|
987
|
+
return ''.join(chars) if chars else '0'
|
|
988
|
+
|
|
989
|
+
def _parse_float(self):
|
|
990
|
+
chars = []
|
|
991
|
+
while True:
|
|
992
|
+
if self._buf:
|
|
993
|
+
char = self._buf.pop(0)
|
|
994
|
+
else:
|
|
995
|
+
char = self._get_char()
|
|
996
|
+
if char in self._whitespace or char == -1:
|
|
997
|
+
break
|
|
998
|
+
if char == 8:
|
|
999
|
+
sys.stdout.write(self.backch)
|
|
1000
|
+
sys.stdout.flush()
|
|
1001
|
+
try:
|
|
1002
|
+
chars.pop()
|
|
1003
|
+
except:
|
|
1004
|
+
pass
|
|
1005
|
+
continue
|
|
1006
|
+
elif chr(char) not in '+-0123456789.eE':
|
|
1007
|
+
self._buf.append(char)
|
|
1008
|
+
break
|
|
1009
|
+
chars.append(chr(char))
|
|
1010
|
+
return ''.join(chars) if chars else '0.0'
|
|
1011
|
+
|
|
1012
|
+
def _parse_complex(self):
|
|
1013
|
+
chars = []
|
|
1014
|
+
while True:
|
|
1015
|
+
if self._buf:
|
|
1016
|
+
char = self._buf.pop(0)
|
|
1017
|
+
else:
|
|
1018
|
+
char = self._get_char()
|
|
1019
|
+
if char in self._whitespace or char == -1:
|
|
1020
|
+
break
|
|
1021
|
+
if char == 8:
|
|
1022
|
+
sys.stdout.write(self.backch)
|
|
1023
|
+
sys.stdout.flush()
|
|
1024
|
+
try:
|
|
1025
|
+
chars.pop()
|
|
1026
|
+
except:
|
|
1027
|
+
pass
|
|
1028
|
+
continue
|
|
1029
|
+
if chr(char) not in '+-0123456789.eEj':
|
|
1030
|
+
self._buf.append(char)
|
|
1031
|
+
break
|
|
1032
|
+
chars.append(chr(char))
|
|
1033
|
+
return ''.join(chars) if chars else '0+0j'
|
|
1034
|
+
|
|
1035
|
+
def _parse_char(self):
|
|
1036
|
+
char = self._read_char()
|
|
1037
|
+
return chr(char) if char not in self._whitespace and char != -1 else '\0'
|
|
1038
|
+
|
|
1039
|
+
def _parse_char_array(self, max_len=1024):
|
|
1040
|
+
chars = []
|
|
1041
|
+
count = 0
|
|
1042
|
+
while count < max_len - 1:
|
|
1043
|
+
char = self._get_char()
|
|
1044
|
+
if char == 8:
|
|
1045
|
+
sys.stdout.write(self.backch)
|
|
1046
|
+
sys.stdout.flush()
|
|
1047
|
+
try:
|
|
1048
|
+
chars.pop()
|
|
1049
|
+
except:
|
|
1050
|
+
pass
|
|
1051
|
+
continue
|
|
1052
|
+
if char in self._whitespace or char == -1:
|
|
1053
|
+
break
|
|
1054
|
+
chars.append(chr(char))
|
|
1055
|
+
count += 1
|
|
1056
|
+
return ''.join(chars)
|
|
1057
|
+
def _parse_ptr(self):
|
|
1058
|
+
chars = []
|
|
1059
|
+
while True:
|
|
1060
|
+
if self._buf:
|
|
1061
|
+
char = self._buf.pop(0)
|
|
1062
|
+
else:
|
|
1063
|
+
char = self._get_char()
|
|
1064
|
+
if char in self._whitespace or char == -1:
|
|
1065
|
+
break
|
|
1066
|
+
if char == 8:
|
|
1067
|
+
sys.stdout.write(self.backch)
|
|
1068
|
+
sys.stdout.flush()
|
|
1069
|
+
try:
|
|
1070
|
+
chars.pop()
|
|
1071
|
+
except:
|
|
1072
|
+
pass
|
|
1073
|
+
continue
|
|
1074
|
+
if chr(char) not in '0123456789abcdefABCDEFx':
|
|
1075
|
+
self._buf.append(char)
|
|
1076
|
+
break
|
|
1077
|
+
chars.append(chr(char))
|
|
1078
|
+
return ''.join(chars) if chars else '0'
|
|
1079
|
+
def __rshift__(self, target):
|
|
1080
|
+
if isinstance(target, ctypes._SimpleCData):
|
|
1081
|
+
target_type = type(target)
|
|
1082
|
+
if target_type == c_void_p:
|
|
1083
|
+
ptr_str = self._parse_ptr()
|
|
1084
|
+
if ptr_str.startswith('0x') or ptr_str.startswith('0X'):
|
|
1085
|
+
val = c_void_p(int(ptr_str, 16))
|
|
1086
|
+
else:
|
|
1087
|
+
val = c_void_p(int(ptr_str) if ptr_str.isdigit() else 0)
|
|
1088
|
+
elif target_type == c_char_p:
|
|
1089
|
+
str_val = self._parse_char_array()
|
|
1090
|
+
val = c_char_p(str_val.encode('utf-8'))
|
|
1091
|
+
ctypes.memmove(target, val, len(str_val.encode('utf-8')))
|
|
1092
|
+
elif target_type == c_wchar_p:
|
|
1093
|
+
str_val = self._parse_char_array()
|
|
1094
|
+
val = c_wchar_p(str_val)
|
|
1095
|
+
ctypes.memmove(target, val, len(str_val) * ctypes.sizeof(c_wchar))
|
|
1096
|
+
elif np.issubdtype(np.dtype(target_type), np.integer):
|
|
1097
|
+
val = target_type(int(self._parse_int()))
|
|
1098
|
+
elif np.issubdtype(np.dtype(target_type), np.floating):
|
|
1099
|
+
val = target_type(float(self._parse_float()))
|
|
1100
|
+
elif np.issubdtype(np.dtype(target_type), np.complexfloating):
|
|
1101
|
+
val = target_type(complex(self._parse_complex()))
|
|
1102
|
+
elif target_type == c_char:
|
|
1103
|
+
val = c_char(self._parse_char().encode('utf-8')[0])
|
|
1104
|
+
elif target_type == c_wchar:
|
|
1105
|
+
val = c_wchar(self._parse_char())
|
|
1106
|
+
else:
|
|
1107
|
+
raise TypeError(f"Unsupported ctypes type: {target_type}")
|
|
1108
|
+
if target_type not in (c_char_p, c_wchar_p):
|
|
1109
|
+
ctypes.memmove(byref(target), byref(val), sizeof(target))
|
|
1110
|
+
elif isinstance(target, (np.generic, np.ndarray)):
|
|
1111
|
+
if isinstance(target, np.generic) or target.ndim == 0:
|
|
1112
|
+
if np.issubdtype(target.dtype, np.integer):
|
|
1113
|
+
val = np.array(self._parse_int(), dtype=target.dtype)
|
|
1114
|
+
elif np.issubdtype(target.dtype, np.floating):
|
|
1115
|
+
val = np.array(self._parse_float(), dtype=target.dtype)
|
|
1116
|
+
elif np.issubdtype(target.dtype, np.complexfloating):
|
|
1117
|
+
val = np.array(self._parse_complex(), dtype=target.dtype)
|
|
1118
|
+
elif np.issubdtype(target.dtype, np.character):
|
|
1119
|
+
val = np.array(self._parse_char(), dtype=target.dtype)
|
|
1120
|
+
else:
|
|
1121
|
+
val = np.array(self._parse_int(), dtype=target.dtype)
|
|
1122
|
+
target[...] = val[()]
|
|
1123
|
+
else:
|
|
1124
|
+
for i in range(target.size):
|
|
1125
|
+
if np.issubdtype(target.dtype, np.integer):
|
|
1126
|
+
val = np.array(self._parse_int(), dtype=target.dtype)
|
|
1127
|
+
elif np.issubdtype(target.dtype, np.floating):
|
|
1128
|
+
val = np.array(self._parse_float(), dtype=target.dtype)
|
|
1129
|
+
elif np.issubdtype(target.dtype, np.complexfloating):
|
|
1130
|
+
val = np.array(self._parse_complex(), dtype=target.dtype)
|
|
1131
|
+
elif np.issubdtype(target.dtype, np.character):
|
|
1132
|
+
val = np.array(self._parse_char(), dtype=target.dtype)
|
|
1133
|
+
else:
|
|
1134
|
+
val = np.array(self._parse_int(), dtype=target.dtype)
|
|
1135
|
+
target.flat[i] = val[()]
|
|
1136
|
+
else:
|
|
1137
|
+
raise TypeError(f"Unsupported target type: {type(target)}")
|
|
1138
|
+
return self
|
|
1139
|
+
__str__ = lambda self:""
|
|
1140
|
+
__repr__ = lambda self:""
|
|
1141
|
+
class OutPutObject:
|
|
1142
|
+
def __lshift__(self, data):
|
|
1143
|
+
sys.stdout.write(str(data))
|
|
1144
|
+
return self
|
|
1145
|
+
__str__ = lambda self:""
|
|
1146
|
+
__repr__ = lambda self:""
|
|
1147
|
+
cin = InPutObject()
|
|
1148
|
+
cout = OutPutObject()
|
|
1149
|
+
endl = "\n"
|
|
938
1150
|
builtins.np = np
|
|
939
1151
|
builtins.T = BHA_bool(1)
|
|
940
1152
|
builtins.F = BHA_bool(0)
|
|
@@ -952,6 +1164,10 @@ builtins.BHA_Function = BHA_Function
|
|
|
952
1164
|
builtins.Ask_BHA = Ask_BHA
|
|
953
1165
|
builtins.Create_BHA = Create_BHA
|
|
954
1166
|
builtins.numba_opt = numba_opt
|
|
1167
|
+
builtins.cin = cin
|
|
1168
|
+
builtins.cout = cout
|
|
1169
|
+
builtins.endl = endl
|
|
1170
|
+
builtins.BHA_Queue = BHA_Queue
|
|
955
1171
|
Tid,Fid = id(builtins.T),id(builtins.F)
|
|
956
1172
|
original_id = builtins.id
|
|
957
1173
|
def fake_id(obj):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bool-hybrid-array
|
|
3
|
-
Version: 9.11.
|
|
3
|
+
Version: 9.11.9
|
|
4
4
|
Summary: 一个高效的布尔数组(密集+稀疏混合存储,节省内存)
|
|
5
5
|
Home-page: https://github.com/BKsell/bool-hybrid-array
|
|
6
6
|
Author: 蔡靖杰
|
|
@@ -614,6 +614,7 @@ print(f"出队2个元素后: {q}") # 输出:BHA_Queue([T,T,F,T,F])
|
|
|
614
614
|
* **9.11.6**:修复从9.11.3版本开始cpython用户无法安装bool-hybrid-array包的问题
|
|
615
615
|
* **9.11.7**:修复TypeError: 'map' object is not reversible的错误
|
|
616
616
|
* **9.11.8**:增加了Windows系统Python3.14的C扩展优化
|
|
617
|
+
* **9.11.9**:修复BHA_Queue的bug,新增cin和cout(使用方式:a = ctypes.c_int();cin >> a;cout << a)
|
|
617
618
|
|
|
618
619
|
|
|
619
620
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
bool_hybrid_array/__init__.py,sha256=QGalf9IbiqJSBW7wmbpduG333dmkQISsLMeQja-qtSg,1077
|
|
2
|
+
bool_hybrid_array/__main__.py,sha256=pjoWN4Noa_K44fqQPqp8H-diKSDf0Da8hdWFgvWUigQ,9083
|
|
3
|
+
bool_hybrid_array/compile_core.pyd,sha256=lriymUZtvs_ryeGM_K8gM33iCIfxRH5Zr5GPKhuNCtw,555520
|
|
4
|
+
bool_hybrid_array/core.c,sha256=VN0qsWCaJc0lEz6zHt7AFJsUcTieM5hkNtSeKh4ilIs,3616205
|
|
5
|
+
bool_hybrid_array/core.cp314-win_amd64.pyd,sha256=bAIpe0dUTBNMVbIDlZoBdtLsN7TmzaOo2KcY16BEvYU,633856
|
|
6
|
+
bool_hybrid_array/core.py,sha256=A1Lwn91T9N9-BhRBDIKJjVzvBVS036Mnaal3bfXN4To,50424
|
|
7
|
+
bool_hybrid_array/秘密.md,sha256=Ii2NvXmv-Ktu04zJsGLcQZvlzT4gOatByE4B2wTK1Ks,48
|
|
8
|
+
bool_hybrid_array/int_array/__init__.py,sha256=HPBdZu5qlXaRI4n_oK6WhnG4ml8H-FP1G44igVxPJIA,6225
|
|
9
|
+
bool_hybrid_array-9.11.9.dist-info/licenses/LICENSE,sha256=Sg4rnGXkBDYkwJCWyxdWp5H60rhVAxpNvFh_l3JWZdY,1070
|
|
10
|
+
bool_hybrid_array-9.11.9.dist-info/METADATA,sha256=8aIKi87Xbs3_J6hkpDGIjFXhE9GiVB2qH2-hJJJXJ7Y,26038
|
|
11
|
+
bool_hybrid_array-9.11.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
bool_hybrid_array-9.11.9.dist-info/top_level.txt,sha256=vk-TD77wuVQsN1rJ6uVWZX4sC_wya_WplRDwQKJoBZM,18
|
|
13
|
+
bool_hybrid_array-9.11.9.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
bool_hybrid_array/__init__.py,sha256=VlUqwA0SmYh5vdHKXT-180u9A3t7Le6Fg9ppgMj8ztc,1077
|
|
2
|
-
bool_hybrid_array/__main__.py,sha256=pjoWN4Noa_K44fqQPqp8H-diKSDf0Da8hdWFgvWUigQ,9083
|
|
3
|
-
bool_hybrid_array/compile_core.pyd,sha256=lriymUZtvs_ryeGM_K8gM33iCIfxRH5Zr5GPKhuNCtw,555520
|
|
4
|
-
bool_hybrid_array/core.c,sha256=b5KMuQ6Ma64wUx-oXYqkx_AR9sTcIO0VUZ6qz_2vDM0,3227011
|
|
5
|
-
bool_hybrid_array/core.py,sha256=uJsVr6GDzCMfDLfvO9LiE0MSjmHodu4yOYwouFpxxFQ,41921
|
|
6
|
-
bool_hybrid_array/秘密.md,sha256=Ii2NvXmv-Ktu04zJsGLcQZvlzT4gOatByE4B2wTK1Ks,48
|
|
7
|
-
bool_hybrid_array/int_array/__init__.py,sha256=HPBdZu5qlXaRI4n_oK6WhnG4ml8H-FP1G44igVxPJIA,6225
|
|
8
|
-
bool_hybrid_array-9.11.8.dist-info/licenses/LICENSE,sha256=Sg4rnGXkBDYkwJCWyxdWp5H60rhVAxpNvFh_l3JWZdY,1070
|
|
9
|
-
bool_hybrid_array-9.11.8.dist-info/METADATA,sha256=deIVm_eXDmWKFWZp65t3-0UB6PZfzprqDiBUmOaSI3U,25923
|
|
10
|
-
bool_hybrid_array-9.11.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
-
bool_hybrid_array-9.11.8.dist-info/top_level.txt,sha256=vk-TD77wuVQsN1rJ6uVWZX4sC_wya_WplRDwQKJoBZM,18
|
|
12
|
-
bool_hybrid_array-9.11.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|