bool-hybrid-array 9.11.8__tar.gz → 9.11.11__tar.gz

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.
Files changed (20) hide show
  1. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/PKG-INFO +8 -2
  2. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/README.md +3 -1
  3. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array/__init__.py +2 -2
  4. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array/__main__.py +1 -3
  5. bool_hybrid_array-9.11.11/bool_hybrid_array/_cppiostream.py +235 -0
  6. bool_hybrid_array-9.11.11/bool_hybrid_array/compile_core.cp314-win_amd64.pyd +0 -0
  7. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array/core.c +1547 -1466
  8. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array/core.py +16 -12
  9. bool_hybrid_array-9.11.11/bool_hybrid_array/int_array/__init__.py +4 -0
  10. bool_hybrid_array-9.11.8/bool_hybrid_array/int_array/__init__.py → bool_hybrid_array-9.11.11/bool_hybrid_array/int_array/core.py +2 -3
  11. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array.egg-info/PKG-INFO +8 -2
  12. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array.egg-info/SOURCES.txt +4 -2
  13. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array.egg-info/requires.txt +3 -0
  14. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/setup.py +10 -4
  15. bool_hybrid_array-9.11.8/bool_hybrid_array/compile_core.pyd +0 -0
  16. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/LICENSE +0 -0
  17. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array//347/247/230/345/257/206.md" +0 -0
  18. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array.egg-info/dependency_links.txt +0 -0
  19. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/bool_hybrid_array.egg-info/top_level.txt +0 -0
  20. {bool_hybrid_array-9.11.8 → bool_hybrid_array-9.11.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bool-hybrid-array
3
- Version: 9.11.8
3
+ Version: 9.11.11
4
4
  Summary: 一个高效的布尔数组(密集+稀疏混合存储,节省内存)
5
5
  Home-page: https://github.com/BKsell/bool-hybrid-array
6
6
  Author: 蔡靖杰
@@ -9,6 +9,8 @@ Project-URL: GitHub 主站, https://github.com/BKsell/bool-hybrid-array
9
9
  Project-URL: GitHub 中文镜像, https://www.github-zh.com/projects/1083175506-bool-hybrid-array
10
10
  Project-URL: Issue 反馈(主站), https://github.com/BKsell/bool-hybrid-array/issues
11
11
  Keywords: boolean array,compact storage
12
+ Classifier: Programming Language :: Cython
13
+ Classifier: Programming Language :: Python
12
14
  Classifier: Programming Language :: Python :: 3
13
15
  Classifier: Programming Language :: Python :: 3.8
14
16
  Classifier: Programming Language :: Python :: 3.9
@@ -29,6 +31,8 @@ Requires-Dist: numpy>=1.19.0
29
31
  Provides-Extra: int-array
30
32
  Provides-Extra: numba-opt
31
33
  Requires-Dist: numba>=0.55.0; extra == "numba-opt"
34
+ Provides-Extra: cython-opt
35
+ Requires-Dist: cython>=3.2.4; extra == "cython-opt"
32
36
  Dynamic: author
33
37
  Dynamic: author-email
34
38
  Dynamic: classifier
@@ -614,7 +618,9 @@ print(f"出队2个元素后: {q}") # 输出:BHA_Queue([T,T,F,T,F])
614
618
  * **9.11.6**:修复从9.11.3版本开始cpython用户无法安装bool-hybrid-array包的问题
615
619
  * **9.11.7**:修复TypeError: 'map' object is not reversible的错误
616
620
  * **9.11.8**:增加了Windows系统Python3.14的C扩展优化
617
-
621
+ * **9.11.9**:修复BHA_Queue的bug,新增cin和cout(使用方式:a = ctypes.c_int();cin >> a;cout << a,支持各种ctypes类型、numpy标量)
622
+ * **9.11.10**:修复cin的AttributeError的错误
623
+ * **9.11.11**:新增cin对EOF的处理
618
624
 
619
625
 
620
626
 
@@ -569,7 +569,9 @@ print(f"出队2个元素后: {q}") # 输出:BHA_Queue([T,T,F,T,F])
569
569
  * **9.11.6**:修复从9.11.3版本开始cpython用户无法安装bool-hybrid-array包的问题
570
570
  * **9.11.7**:修复TypeError: 'map' object is not reversible的错误
571
571
  * **9.11.8**:增加了Windows系统Python3.14的C扩展优化
572
-
572
+ * **9.11.9**:修复BHA_Queue的bug,新增cin和cout(使用方式:a = ctypes.c_int();cin >> a;cout << a,支持各种ctypes类型、numpy标量)
573
+ * **9.11.10**:修复cin的AttributeError的错误
574
+ * **9.11.11**:新增cin对EOF的处理
573
575
 
574
576
 
575
577
 
@@ -1,12 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import sys
3
3
  from types import ModuleType,FunctionType
4
- try:from . import compile_core
4
+ try:from . import compile_core as core
5
5
  except:from . import core
6
6
  from .core import __builtins__,builtins
7
7
  try:from . import int_array
8
8
  except:pass
9
- __version__ = "9.11.8"
9
+ __version__ = "9.11.10"
10
10
  public_objects = []
11
11
  for name in dir(core):
12
12
  if not name.startswith("_"):
@@ -1,8 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  from .__init__ import *
3
- import io
4
-
5
- sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore')
6
3
 
7
4
  # 创建实例
8
5
 
@@ -309,3 +306,4 @@ print(f"第二次出队: {q.dequeue()}") # 输出:F(直接从 self.b 弹出
309
306
 
310
307
  print(f"出队2个元素后: {q}") # 输出:BHA_Queue([T,T,F,T,F])
311
308
 
309
+
@@ -0,0 +1,235 @@
1
+ import sys
2
+ from ctypes import *
3
+ import ctypes
4
+ import numpy as np
5
+ try:
6
+ import msvcrt
7
+ except:
8
+ pass
9
+ class InPutObject:
10
+ def __init__(self):
11
+ self._stdout = sys.stdout
12
+ self.backch = " \b"
13
+ if sys.platform == "win32":
14
+ self._get_char = lambda: ord(msvcrt.getche())
15
+ self.eof = 26
16
+ else:
17
+ libc_path = "libc.so.6" if sys.platform == "linux" else "libSystem.B.dylib"
18
+ try:self.libc = ctypes.cdll.LoadLibrary(libc_path)
19
+ except:self.libc= ctypes.CDLL("libc.so")
20
+ self._get_char = lambda:(c:=self.libc.getchar(),
21
+ self._stdout.write(chr(c) if c != -1 else '\0'),self._stdout.flush())[0]
22
+ self.eof = -1
23
+ self._whitespace = {ord('\n'), ord('\t'), ord(' '), 0, ord("\r")}
24
+ self.getchar = self._get_char
25
+ self._buf = []
26
+ self.eofbit = False
27
+
28
+ def _read_char(self):
29
+ while True:
30
+ if self._buf:char = self._buf.pop(0)
31
+ else:char = self._get_char()
32
+ if char in self._whitespace:
33
+ continue
34
+ if char == self.eof:
35
+ self.eofbit = True
36
+ return 0
37
+ return char
38
+
39
+ def _parse_int(self):
40
+ chars = []
41
+ while True:
42
+ if self._buf:
43
+ char = self._buf.pop(0)
44
+ else:
45
+ char = self._get_char()
46
+ if char in self._whitespace or char==self.eof:
47
+ self.eofbit = char==self.eof
48
+ break
49
+ if char == 8:
50
+ sys.stdout.write(self.backch)
51
+ sys.stdout.flush()
52
+ try:
53
+ chars.pop()
54
+ except:
55
+ pass
56
+ continue
57
+ elif chr(char) not in '+-0123456789':
58
+ self._buf.append(char)
59
+ break
60
+ else:
61
+ chars.append(chr(char))
62
+ return ''.join(chars) if chars else '0'
63
+
64
+ def _parse_float(self):
65
+ chars = []
66
+ while True:
67
+ if self._buf:
68
+ char = self._buf.pop(0)
69
+ else:
70
+ char = self._get_char()
71
+ if char in self._whitespace or char == self.eof:
72
+ self.eofbit = char==self.eof
73
+ break
74
+ if char == 8:
75
+ sys.stdout.write(self.backch)
76
+ sys.stdout.flush()
77
+ try:
78
+ chars.pop()
79
+ except:
80
+ pass
81
+ continue
82
+ elif chr(char) not in '+-0123456789.eE':
83
+ self._buf.append(char)
84
+ break
85
+ chars.append(chr(char))
86
+ return ''.join(chars) if chars else '0.0'
87
+
88
+ def _parse_complex(self):
89
+ chars = []
90
+ while True:
91
+ if self._buf:
92
+ char = self._buf.pop(0)
93
+ else:
94
+ char = self._get_char()
95
+ if char in self._whitespace or char == self.eof:
96
+ self.eofbit = char==self.eof
97
+ break
98
+ if char == 8:
99
+ sys.stdout.write(self.backch)
100
+ sys.stdout.flush()
101
+ try:
102
+ chars.pop()
103
+ except:
104
+ pass
105
+ continue
106
+ if chr(char) not in '+-0123456789.eEj':
107
+ self._buf.append(char)
108
+ break
109
+ chars.append(chr(char))
110
+ return ''.join(chars) if chars else '0+0j'
111
+
112
+ def _parse_char(self):
113
+ char = self._read_char()
114
+ return chr(char) if char not in self._whitespace else '\0'
115
+
116
+ def _parse_char_array(self, max_len=1024):
117
+ chars = []
118
+ count = 0
119
+ while count < max_len - 1:
120
+ if self._buf:char = self._buf.pop(0)
121
+ else:char = self._get_char()
122
+ if char == 8:
123
+ sys.stdout.write(self.backch)
124
+ sys.stdout.flush()
125
+ try:
126
+ chars.pop()
127
+ except:
128
+ pass
129
+ continue
130
+ if char in self._whitespace or char == self.eof:
131
+ self.eofbit = char==self.eof
132
+ break
133
+ chars.append(chr(char))
134
+ count += 1
135
+ return ''.join(chars)
136
+ def _parse_ptr(self):
137
+ chars = []
138
+ while True:
139
+ if self._buf:
140
+ char = self._buf.pop(0)
141
+ else:
142
+ char = self._get_char()
143
+ if char in self._whitespace or char == self.eof:
144
+ self.eofbit = char==self.eof
145
+ break
146
+ if char == 8:
147
+ sys.stdout.write(self.backch)
148
+ sys.stdout.flush()
149
+ try:
150
+ chars.pop()
151
+ except:
152
+ pass
153
+ continue
154
+ if chr(char) not in '0123456789abcdefABCDEFx':
155
+ self._buf.append(char)
156
+ break
157
+ chars.append(chr(char))
158
+ return ''.join(chars) if chars else '0'
159
+ def __rshift__(self, target):
160
+ if self.eofbit:
161
+ raise EOFError("Input stream reached EOF while parsing integer")
162
+ if isinstance(target, ctypes._SimpleCData):
163
+ target_type = type(target)
164
+ if target_type == c_void_p:
165
+ ptr_str = self._parse_ptr()
166
+ if ptr_str.startswith('0x') or ptr_str.startswith('0X'):
167
+ val = c_void_p(int(ptr_str, 16))
168
+ else:
169
+ val = c_void_p(int(ptr_str) if ptr_str.isdigit() else 0)
170
+ elif target_type == c_char_p:
171
+ str_val = self._parse_char_array()
172
+ val = c_char_p(str_val.encode('utf-8'))
173
+ ctypes.memmove(target, val, len(str_val.encode('utf-8')))
174
+ elif target_type == c_wchar_p:
175
+ str_val = self._parse_char_array()
176
+ val = c_wchar_p(str_val)
177
+ ctypes.memmove(target, val, len(str_val) * ctypes.sizeof(c_wchar))
178
+ elif np.issubdtype(np.dtype(target_type), np.integer):
179
+ val = target_type(int(self._parse_int()))
180
+ elif np.issubdtype(np.dtype(target_type), np.floating):
181
+ val = target_type(float(self._parse_float()))
182
+ elif np.issubdtype(np.dtype(target_type), np.complexfloating):
183
+ val = target_type(complex(self._parse_complex()))
184
+ elif target_type == c_char:
185
+ val = c_char(self._parse_char().encode('utf-8')[0])
186
+ elif target_type == c_wchar:
187
+ val = c_wchar(self._parse_char())
188
+ else:
189
+ raise TypeError(f"Unsupported ctypes type: {target_type}")
190
+ if target_type not in (c_char_p, c_wchar_p):
191
+ ctypes.memmove(byref(target), byref(val), sizeof(target))
192
+ elif isinstance(target, (np.generic, np.ndarray)):
193
+ if isinstance(target, np.generic) or target.ndim == 0:
194
+ if np.issubdtype(target.dtype, np.integer):
195
+ val = np.array(self._parse_int(), dtype=target.dtype)
196
+ elif np.issubdtype(target.dtype, np.floating):
197
+ val = np.array(self._parse_float(), dtype=target.dtype)
198
+ elif np.issubdtype(target.dtype, np.complexfloating):
199
+ val = np.array(self._parse_complex(), dtype=target.dtype)
200
+ elif np.issubdtype(target.dtype, np.character):
201
+ val = np.array(self._parse_char(), dtype=target.dtype)
202
+ else:
203
+ val = np.array(self._parse_int(), dtype=target.dtype)
204
+ target[...] = val[()]
205
+ else:
206
+ for i in range(target.size):
207
+ if np.issubdtype(target.dtype, np.integer):
208
+ val = np.array(self._parse_int(), dtype=target.dtype)
209
+ elif np.issubdtype(target.dtype, np.floating):
210
+ val = np.array(self._parse_float(), dtype=target.dtype)
211
+ elif np.issubdtype(target.dtype, np.complexfloating):
212
+ val = np.array(self._parse_complex(), dtype=target.dtype)
213
+ elif np.issubdtype(target.dtype, np.character):
214
+ val = np.array(self._parse_char(), dtype=target.dtype)
215
+ else:
216
+ val = np.array(self._parse_int(), dtype=target.dtype)
217
+ target.flat[i] = val[()]
218
+ else:
219
+ raise TypeError(f"Unsupported target type: {type(target)}")
220
+ return self
221
+ __str__ = lambda self:""
222
+ __repr__ = lambda self:""
223
+ __bool__ = lambda self:not self._buf or self.eofbit
224
+ def clear(self):
225
+ self._buf.clear()
226
+ self.eofbit = False
227
+ class OutPutObject:
228
+ def __lshift__(self, data):
229
+ sys.stdout.write(str(data))
230
+ return self
231
+ __str__ = lambda self:""
232
+ __repr__ = lambda self:""
233
+ cin = InPutObject()
234
+ cout = OutPutObject()
235
+ endl = "\r\n"