bool-hybrid-array 9.11.10__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.
- bool_hybrid_array/__init__.py +1 -1
- bool_hybrid_array/_cppiostream.py +33 -14
- bool_hybrid_array/{compile_core.pyd → compile_core.cp314-win_amd64.pyd} +0 -0
- bool_hybrid_array/core.c +228 -228
- bool_hybrid_array/core.py +4 -4
- {bool_hybrid_array-9.11.10.dist-info → bool_hybrid_array-9.11.11.dist-info}/METADATA +6 -2
- bool_hybrid_array-9.11.11.dist-info/RECORD +14 -0
- {bool_hybrid_array-9.11.10.dist-info → bool_hybrid_array-9.11.11.dist-info}/WHEEL +1 -1
- bool_hybrid_array-9.11.10.dist-info/RECORD +0 -14
- {bool_hybrid_array-9.11.10.dist-info → bool_hybrid_array-9.11.11.dist-info}/licenses/LICENSE +0 -0
- {bool_hybrid_array-9.11.10.dist-info → bool_hybrid_array-9.11.11.dist-info}/top_level.txt +0 -0
bool_hybrid_array/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from ctypes import *
|
|
3
3
|
import ctypes
|
|
4
|
+
import numpy as np
|
|
4
5
|
try:
|
|
5
6
|
import msvcrt
|
|
6
7
|
except:
|
|
@@ -8,25 +9,31 @@ except:
|
|
|
8
9
|
class InPutObject:
|
|
9
10
|
def __init__(self):
|
|
10
11
|
self._stdout = sys.stdout
|
|
12
|
+
self.backch = " \b"
|
|
11
13
|
if sys.platform == "win32":
|
|
12
14
|
self._get_char = lambda: ord(msvcrt.getche())
|
|
13
|
-
self.
|
|
15
|
+
self.eof = 26
|
|
14
16
|
else:
|
|
15
17
|
libc_path = "libc.so.6" if sys.platform == "linux" else "libSystem.B.dylib"
|
|
16
|
-
self.libc = ctypes.cdll.LoadLibrary(libc_path)
|
|
17
|
-
self.
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
20
23
|
self._whitespace = {ord('\n'), ord('\t'), ord(' '), 0, ord("\r")}
|
|
21
24
|
self.getchar = self._get_char
|
|
22
25
|
self._buf = []
|
|
26
|
+
self.eofbit = False
|
|
23
27
|
|
|
24
28
|
def _read_char(self):
|
|
25
29
|
while True:
|
|
26
30
|
if self._buf:char = self._buf.pop(0)
|
|
27
31
|
else:char = self._get_char()
|
|
28
|
-
if char in self._whitespace
|
|
32
|
+
if char in self._whitespace:
|
|
29
33
|
continue
|
|
34
|
+
if char == self.eof:
|
|
35
|
+
self.eofbit = True
|
|
36
|
+
return 0
|
|
30
37
|
return char
|
|
31
38
|
|
|
32
39
|
def _parse_int(self):
|
|
@@ -36,7 +43,8 @@ class InPutObject:
|
|
|
36
43
|
char = self._buf.pop(0)
|
|
37
44
|
else:
|
|
38
45
|
char = self._get_char()
|
|
39
|
-
if char in self._whitespace or char
|
|
46
|
+
if char in self._whitespace or char==self.eof:
|
|
47
|
+
self.eofbit = char==self.eof
|
|
40
48
|
break
|
|
41
49
|
if char == 8:
|
|
42
50
|
sys.stdout.write(self.backch)
|
|
@@ -60,7 +68,8 @@ class InPutObject:
|
|
|
60
68
|
char = self._buf.pop(0)
|
|
61
69
|
else:
|
|
62
70
|
char = self._get_char()
|
|
63
|
-
if char in self._whitespace or char ==
|
|
71
|
+
if char in self._whitespace or char == self.eof:
|
|
72
|
+
self.eofbit = char==self.eof
|
|
64
73
|
break
|
|
65
74
|
if char == 8:
|
|
66
75
|
sys.stdout.write(self.backch)
|
|
@@ -83,7 +92,8 @@ class InPutObject:
|
|
|
83
92
|
char = self._buf.pop(0)
|
|
84
93
|
else:
|
|
85
94
|
char = self._get_char()
|
|
86
|
-
if char in self._whitespace or char ==
|
|
95
|
+
if char in self._whitespace or char == self.eof:
|
|
96
|
+
self.eofbit = char==self.eof
|
|
87
97
|
break
|
|
88
98
|
if char == 8:
|
|
89
99
|
sys.stdout.write(self.backch)
|
|
@@ -101,13 +111,14 @@ class InPutObject:
|
|
|
101
111
|
|
|
102
112
|
def _parse_char(self):
|
|
103
113
|
char = self._read_char()
|
|
104
|
-
return chr(char) if char not in self._whitespace
|
|
114
|
+
return chr(char) if char not in self._whitespace else '\0'
|
|
105
115
|
|
|
106
116
|
def _parse_char_array(self, max_len=1024):
|
|
107
117
|
chars = []
|
|
108
118
|
count = 0
|
|
109
119
|
while count < max_len - 1:
|
|
110
|
-
char = self.
|
|
120
|
+
if self._buf:char = self._buf.pop(0)
|
|
121
|
+
else:char = self._get_char()
|
|
111
122
|
if char == 8:
|
|
112
123
|
sys.stdout.write(self.backch)
|
|
113
124
|
sys.stdout.flush()
|
|
@@ -116,7 +127,8 @@ class InPutObject:
|
|
|
116
127
|
except:
|
|
117
128
|
pass
|
|
118
129
|
continue
|
|
119
|
-
if char in self._whitespace or char ==
|
|
130
|
+
if char in self._whitespace or char == self.eof:
|
|
131
|
+
self.eofbit = char==self.eof
|
|
120
132
|
break
|
|
121
133
|
chars.append(chr(char))
|
|
122
134
|
count += 1
|
|
@@ -128,7 +140,8 @@ class InPutObject:
|
|
|
128
140
|
char = self._buf.pop(0)
|
|
129
141
|
else:
|
|
130
142
|
char = self._get_char()
|
|
131
|
-
if char in self._whitespace or char ==
|
|
143
|
+
if char in self._whitespace or char == self.eof:
|
|
144
|
+
self.eofbit = char==self.eof
|
|
132
145
|
break
|
|
133
146
|
if char == 8:
|
|
134
147
|
sys.stdout.write(self.backch)
|
|
@@ -144,6 +157,8 @@ class InPutObject:
|
|
|
144
157
|
chars.append(chr(char))
|
|
145
158
|
return ''.join(chars) if chars else '0'
|
|
146
159
|
def __rshift__(self, target):
|
|
160
|
+
if self.eofbit:
|
|
161
|
+
raise EOFError("Input stream reached EOF while parsing integer")
|
|
147
162
|
if isinstance(target, ctypes._SimpleCData):
|
|
148
163
|
target_type = type(target)
|
|
149
164
|
if target_type == c_void_p:
|
|
@@ -205,6 +220,10 @@ class InPutObject:
|
|
|
205
220
|
return self
|
|
206
221
|
__str__ = lambda self:""
|
|
207
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
|
|
208
227
|
class OutPutObject:
|
|
209
228
|
def __lshift__(self, data):
|
|
210
229
|
sys.stdout.write(str(data))
|
|
@@ -213,4 +232,4 @@ class OutPutObject:
|
|
|
213
232
|
__repr__ = lambda self:""
|
|
214
233
|
cin = InPutObject()
|
|
215
234
|
cout = OutPutObject()
|
|
216
|
-
endl = "\n"
|
|
235
|
+
endl = "\r\n"
|
|
Binary file
|