bool-hybrid-array 9.11.9__py3-none-any.whl → 9.11.10__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.
@@ -6,7 +6,7 @@ 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,216 @@
1
+ import sys
2
+ from ctypes import *
3
+ import ctypes
4
+ try:
5
+ import msvcrt
6
+ except:
7
+ pass
8
+ class InPutObject:
9
+ def __init__(self):
10
+ self._stdout = sys.stdout
11
+ if sys.platform == "win32":
12
+ self._get_char = lambda: ord(msvcrt.getche())
13
+ self.backch = " \b"
14
+ else:
15
+ libc_path = "libc.so.6" if sys.platform == "linux" else "libSystem.B.dylib"
16
+ self.libc = ctypes.cdll.LoadLibrary(libc_path)
17
+ self._get_char = lambda:(c:=ord(self.libc.getchar()),
18
+ self._stdout.write(chr(c)),self._stdout.flush())[0]
19
+ self.backch = "\b \b"
20
+ self._whitespace = {ord('\n'), ord('\t'), ord(' '), 0, ord("\r")}
21
+ self.getchar = self._get_char
22
+ self._buf = []
23
+
24
+ def _read_char(self):
25
+ while True:
26
+ if self._buf:char = self._buf.pop(0)
27
+ else:char = self._get_char()
28
+ if char in self._whitespace or char == -1:
29
+ continue
30
+ return char
31
+
32
+ def _parse_int(self):
33
+ chars = []
34
+ while True:
35
+ if self._buf:
36
+ char = self._buf.pop(0)
37
+ else:
38
+ char = self._get_char()
39
+ if char in self._whitespace or char == -1:
40
+ break
41
+ if char == 8:
42
+ sys.stdout.write(self.backch)
43
+ sys.stdout.flush()
44
+ try:
45
+ chars.pop()
46
+ except:
47
+ pass
48
+ continue
49
+ elif chr(char) not in '+-0123456789':
50
+ self._buf.append(char)
51
+ break
52
+ else:
53
+ chars.append(chr(char))
54
+ return ''.join(chars) if chars else '0'
55
+
56
+ def _parse_float(self):
57
+ chars = []
58
+ while True:
59
+ if self._buf:
60
+ char = self._buf.pop(0)
61
+ else:
62
+ char = self._get_char()
63
+ if char in self._whitespace or char == -1:
64
+ break
65
+ if char == 8:
66
+ sys.stdout.write(self.backch)
67
+ sys.stdout.flush()
68
+ try:
69
+ chars.pop()
70
+ except:
71
+ pass
72
+ continue
73
+ elif chr(char) not in '+-0123456789.eE':
74
+ self._buf.append(char)
75
+ break
76
+ chars.append(chr(char))
77
+ return ''.join(chars) if chars else '0.0'
78
+
79
+ def _parse_complex(self):
80
+ chars = []
81
+ while True:
82
+ if self._buf:
83
+ char = self._buf.pop(0)
84
+ else:
85
+ char = self._get_char()
86
+ if char in self._whitespace or char == -1:
87
+ break
88
+ if char == 8:
89
+ sys.stdout.write(self.backch)
90
+ sys.stdout.flush()
91
+ try:
92
+ chars.pop()
93
+ except:
94
+ pass
95
+ continue
96
+ if chr(char) not in '+-0123456789.eEj':
97
+ self._buf.append(char)
98
+ break
99
+ chars.append(chr(char))
100
+ return ''.join(chars) if chars else '0+0j'
101
+
102
+ def _parse_char(self):
103
+ char = self._read_char()
104
+ return chr(char) if char not in self._whitespace and char != -1 else '\0'
105
+
106
+ def _parse_char_array(self, max_len=1024):
107
+ chars = []
108
+ count = 0
109
+ while count < max_len - 1:
110
+ char = self._get_char()
111
+ if char == 8:
112
+ sys.stdout.write(self.backch)
113
+ sys.stdout.flush()
114
+ try:
115
+ chars.pop()
116
+ except:
117
+ pass
118
+ continue
119
+ if char in self._whitespace or char == -1:
120
+ break
121
+ chars.append(chr(char))
122
+ count += 1
123
+ return ''.join(chars)
124
+ def _parse_ptr(self):
125
+ chars = []
126
+ while True:
127
+ if self._buf:
128
+ char = self._buf.pop(0)
129
+ else:
130
+ char = self._get_char()
131
+ if char in self._whitespace or char == -1:
132
+ break
133
+ if char == 8:
134
+ sys.stdout.write(self.backch)
135
+ sys.stdout.flush()
136
+ try:
137
+ chars.pop()
138
+ except:
139
+ pass
140
+ continue
141
+ if chr(char) not in '0123456789abcdefABCDEFx':
142
+ self._buf.append(char)
143
+ break
144
+ chars.append(chr(char))
145
+ return ''.join(chars) if chars else '0'
146
+ def __rshift__(self, target):
147
+ if isinstance(target, ctypes._SimpleCData):
148
+ target_type = type(target)
149
+ if target_type == c_void_p:
150
+ ptr_str = self._parse_ptr()
151
+ if ptr_str.startswith('0x') or ptr_str.startswith('0X'):
152
+ val = c_void_p(int(ptr_str, 16))
153
+ else:
154
+ val = c_void_p(int(ptr_str) if ptr_str.isdigit() else 0)
155
+ elif target_type == c_char_p:
156
+ str_val = self._parse_char_array()
157
+ val = c_char_p(str_val.encode('utf-8'))
158
+ ctypes.memmove(target, val, len(str_val.encode('utf-8')))
159
+ elif target_type == c_wchar_p:
160
+ str_val = self._parse_char_array()
161
+ val = c_wchar_p(str_val)
162
+ ctypes.memmove(target, val, len(str_val) * ctypes.sizeof(c_wchar))
163
+ elif np.issubdtype(np.dtype(target_type), np.integer):
164
+ val = target_type(int(self._parse_int()))
165
+ elif np.issubdtype(np.dtype(target_type), np.floating):
166
+ val = target_type(float(self._parse_float()))
167
+ elif np.issubdtype(np.dtype(target_type), np.complexfloating):
168
+ val = target_type(complex(self._parse_complex()))
169
+ elif target_type == c_char:
170
+ val = c_char(self._parse_char().encode('utf-8')[0])
171
+ elif target_type == c_wchar:
172
+ val = c_wchar(self._parse_char())
173
+ else:
174
+ raise TypeError(f"Unsupported ctypes type: {target_type}")
175
+ if target_type not in (c_char_p, c_wchar_p):
176
+ ctypes.memmove(byref(target), byref(val), sizeof(target))
177
+ elif isinstance(target, (np.generic, np.ndarray)):
178
+ if isinstance(target, np.generic) or target.ndim == 0:
179
+ if np.issubdtype(target.dtype, np.integer):
180
+ val = np.array(self._parse_int(), dtype=target.dtype)
181
+ elif np.issubdtype(target.dtype, np.floating):
182
+ val = np.array(self._parse_float(), dtype=target.dtype)
183
+ elif np.issubdtype(target.dtype, np.complexfloating):
184
+ val = np.array(self._parse_complex(), dtype=target.dtype)
185
+ elif np.issubdtype(target.dtype, np.character):
186
+ val = np.array(self._parse_char(), dtype=target.dtype)
187
+ else:
188
+ val = np.array(self._parse_int(), dtype=target.dtype)
189
+ target[...] = val[()]
190
+ else:
191
+ for i in range(target.size):
192
+ if np.issubdtype(target.dtype, np.integer):
193
+ val = np.array(self._parse_int(), dtype=target.dtype)
194
+ elif np.issubdtype(target.dtype, np.floating):
195
+ val = np.array(self._parse_float(), dtype=target.dtype)
196
+ elif np.issubdtype(target.dtype, np.complexfloating):
197
+ val = np.array(self._parse_complex(), dtype=target.dtype)
198
+ elif np.issubdtype(target.dtype, np.character):
199
+ val = np.array(self._parse_char(), dtype=target.dtype)
200
+ else:
201
+ val = np.array(self._parse_int(), dtype=target.dtype)
202
+ target.flat[i] = val[()]
203
+ else:
204
+ raise TypeError(f"Unsupported target type: {type(target)}")
205
+ return self
206
+ __str__ = lambda self:""
207
+ __repr__ = lambda self:""
208
+ class OutPutObject:
209
+ def __lshift__(self, data):
210
+ sys.stdout.write(str(data))
211
+ return self
212
+ __str__ = lambda self:""
213
+ __repr__ = lambda self:""
214
+ cin = InPutObject()
215
+ cout = OutPutObject()
216
+ endl = "\n"
Binary file