bool-hybrid-array 9.11.9__py3-none-any.whl → 9.11.11__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.
@@ -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.9"
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"