pybase16384 0.3.6__cp39-cp39-win_amd64.whl → 0.3.8__cp39-cp39-win_amd64.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.

Potentially problematic release.


This version of pybase16384 might be problematic. Click here for more details.

Binary file
@@ -1,23 +1,29 @@
1
1
  # cython: language_level=3
2
2
  # cython: cdivision=True
3
- from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_Check, PyBytes_Size
3
+ from cpython.bytes cimport (PyBytes_AS_STRING, PyBytes_Check,
4
+ PyBytes_FromStringAndSize, PyBytes_GET_SIZE)
4
5
  from cpython.mem cimport PyMem_Free, PyMem_Malloc
5
- from cpython.object cimport PyObject_HasAttrString
6
+ from cpython.object cimport PyObject, PyObject_HasAttrString
6
7
  from libc.stdint cimport int32_t, uint8_t
8
+ from libc.string cimport memcpy
7
9
 
8
10
  from pybase16384.backends.cython.base16384 cimport (
9
- BASE16384_DECBUFSZ, BASE16384_ENCBUFSZ, BASE16384_FLAG_NOHEADER,
10
- BASE16384_FLAG_SUM_CHECK_ON_REMAIN, BASE16384_SIMPLE_SUM_INIT_VALUE,
11
- b14_decode, b14_decode_fd, b14_decode_fd_detailed, b14_decode_file,
12
- b14_decode_file_detailed, b14_decode_len, b14_encode, b14_encode_fd,
11
+ BASE16384_DECBUFSZ, BASE16384_ENCBUFSZ,
12
+ BASE16384_FLAG_DO_SUM_CHECK_FORCELY, BASE16384_FLAG_NOHEADER,
13
+ BASE16384_FLAG_SUM_CHECK_ON_REMAIN, b14_decode, b14_decode_fd,
14
+ b14_decode_fd_detailed, b14_decode_file, b14_decode_file_detailed,
15
+ b14_decode_len, b14_decode_safe, b14_decode_stream,
16
+ b14_decode_stream_detailed, b14_encode, b14_encode_fd,
13
17
  b14_encode_fd_detailed, b14_encode_file, b14_encode_file_detailed,
14
- b14_encode_len, base16384_err_fopen_input_file,
18
+ b14_encode_len, b14_encode_safe, b14_encode_stream,
19
+ b14_encode_stream_detailed, base16384_err_fopen_input_file,
15
20
  base16384_err_fopen_output_file, base16384_err_get_file_size,
16
21
  base16384_err_invalid_commandline_parameter,
17
22
  base16384_err_invalid_decoding_checksum, base16384_err_invalid_file_name,
18
23
  base16384_err_map_input_file, base16384_err_ok,
19
24
  base16384_err_open_input_file, base16384_err_read_file, base16384_err_t,
20
- base16384_err_write_file, pybase16384_64bits)
25
+ base16384_err_write_file, base16384_io_function_t, base16384_stream_t,
26
+ pybase16384_64bits)
21
27
 
22
28
  from pathlib import Path
23
29
 
@@ -25,7 +31,7 @@ ENCBUFSZ = BASE16384_ENCBUFSZ
25
31
  DECBUFSZ = BASE16384_DECBUFSZ
26
32
  FLAG_NOHEADER = BASE16384_FLAG_NOHEADER
27
33
  FLAG_SUM_CHECK_ON_REMAIN = BASE16384_FLAG_SUM_CHECK_ON_REMAIN
28
- SIMPLE_SUM_INIT_VALUE = BASE16384_SIMPLE_SUM_INIT_VALUE
34
+ FLAG_DO_SUM_CHECK_FORCELY = BASE16384_FLAG_DO_SUM_CHECK_FORCELY
29
35
 
30
36
  cdef inline bytes ensure_bytes(object inp):
31
37
  if isinstance(inp, unicode):
@@ -65,6 +71,22 @@ cpdef inline bytes _encode(const uint8_t[::1] data):
65
71
  finally:
66
72
  PyMem_Free(output_buf)
67
73
 
74
+ cpdef inline bytes _encode_safe(const uint8_t[::1] data):
75
+ cdef size_t length = data.shape[0]
76
+ cdef size_t output_size = <size_t> b14_encode_len(<int>length)
77
+ cdef char *output_buf = <char*>PyMem_Malloc(output_size)
78
+ if output_buf == NULL:
79
+ raise MemoryError
80
+ cdef int count
81
+ with nogil:
82
+ count = b14_encode_safe(<const char*> &data[0],
83
+ <int>length,
84
+ output_buf) # encode 整数倍的那个
85
+ try:
86
+ return <bytes>output_buf[:count]
87
+ finally:
88
+ PyMem_Free(output_buf)
89
+
68
90
  cpdef inline bytes _decode(const uint8_t[::1] data):
69
91
  cdef size_t length = data.shape[0]
70
92
  cdef size_t output_size = <size_t> b14_decode_len(<int>length, 0) + 16
@@ -81,6 +103,22 @@ cpdef inline bytes _decode(const uint8_t[::1] data):
81
103
  finally:
82
104
  PyMem_Free(output_buf)
83
105
 
106
+ cpdef inline bytes _decode_safe(const uint8_t[::1] data):
107
+ cdef size_t length = data.shape[0]
108
+ cdef size_t output_size = <size_t> b14_decode_len(<int>length, 0)
109
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
110
+ if output_buf == NULL:
111
+ raise MemoryError
112
+ cdef int count
113
+ with nogil:
114
+ count = b14_decode_safe(<const char *> &data[0],
115
+ <int> length,
116
+ output_buf) # decode
117
+ try:
118
+ return <bytes> output_buf[:count]
119
+ finally:
120
+ PyMem_Free(output_buf)
121
+
84
122
  cpdef inline int _encode_into(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
85
123
  cdef size_t input_size = data.shape[0]
86
124
  cdef size_t output_size = <size_t> b14_encode_len(<int> input_size)
@@ -92,6 +130,17 @@ cpdef inline int _encode_into(const uint8_t[::1] data, uint8_t[::1] dest) except
92
130
  <int> input_size,
93
131
  <char *> &dest[0])
94
132
 
133
+ cpdef inline int _encode_into_safe(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
134
+ cdef size_t input_size = data.shape[0]
135
+ cdef size_t output_size = <size_t> b14_encode_len(<int> input_size)
136
+ cdef size_t output_buf_size = dest.shape[0]
137
+ if output_buf_size < output_size:
138
+ raise ValueError("Buffer is too small to hold result")
139
+ with nogil:
140
+ return b14_encode_safe(<const char *> &data[0],
141
+ <int> input_size,
142
+ <char *> &dest[0])
143
+
95
144
  cpdef inline int _decode_into(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
96
145
  cdef size_t input_size = data.shape[0]
97
146
  cdef size_t output_size = <size_t> b14_decode_len(<int> input_size, 0)
@@ -103,6 +152,16 @@ cpdef inline int _decode_into(const uint8_t[::1] data, uint8_t[::1] dest) except
103
152
  <int> input_size,
104
153
  <char *> &dest[0])
105
154
 
155
+ cpdef inline int _decode_into_safe(const uint8_t[::1] data, uint8_t[::1] dest) except -1:
156
+ cdef size_t input_size = data.shape[0]
157
+ cdef size_t output_size = <size_t> b14_decode_len(<int> input_size, 0)
158
+ cdef size_t output_buf_size = dest.shape[0]
159
+ if output_buf_size < output_size:
160
+ raise ValueError("Buffer is too small to hold result")
161
+ with nogil:
162
+ return b14_decode_safe(<const char *> &data[0],
163
+ <int> input_size,
164
+ <char *> &dest[0])
106
165
 
107
166
  def encode_file(object input,
108
167
  object output,
@@ -135,7 +194,7 @@ def encode_file(object input,
135
194
  first_check = 0
136
195
  if not PyBytes_Check(chunk):
137
196
  raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
138
- size = PyBytes_Size(chunk)
197
+ size = PyBytes_GET_SIZE(chunk)
139
198
  if <int32_t> size < current_buf_len: # 数据不够了 要减小一次读取的量
140
199
  if buf_rate > 1: # 重新设置一次读取的大小 重新设置流的位置 当然要是已经是一次读取7字节了 那就不能再变小了 直接encode吧
141
200
  buf_rate = buf_rate / 2
@@ -151,6 +210,53 @@ def encode_file(object input,
151
210
  finally:
152
211
  PyMem_Free(output_buf)
153
212
 
213
+ def encode_file_safe(object input,
214
+ object output,
215
+ bint write_head = False,
216
+ int32_t buf_rate = 10):
217
+ if not PyFile_Check(input):
218
+ raise TypeError("input except a file-like object, got %s" % type(input).__name__)
219
+ if not PyFile_Check(output):
220
+ raise TypeError("output except a file-like object, got %s" % type(output).__name__)
221
+ if buf_rate <= 0:
222
+ buf_rate = 1
223
+
224
+ if write_head:
225
+ output.write(b'\xfe\xff')
226
+
227
+ cdef int32_t current_buf_len = buf_rate * 7 # 一次读取这么多字节
228
+ cdef size_t output_size = <size_t> b14_encode_len(<int> current_buf_len) # 因为encode_len不是单调的 这16备用
229
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
230
+ if output_buf == NULL:
231
+ raise MemoryError
232
+
233
+ cdef Py_ssize_t size
234
+ cdef uint8_t first_check = 1 # 检查一次就行了 怎么可能出现第一次读出来是bytes 以后又变卦了的对象呢 不会吧不会吧
235
+ cdef int count = 0
236
+ cdef const char *chunk_ptr
237
+ try:
238
+ while True:
239
+ chunk = input.read(current_buf_len)
240
+ if first_check:
241
+ first_check = 0
242
+ if not PyBytes_Check(chunk):
243
+ raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
244
+ size = PyBytes_GET_SIZE(chunk)
245
+ if <int32_t> size < current_buf_len: # 数据不够了 要减小一次读取的量
246
+ if buf_rate > 1: # 重新设置一次读取的大小 重新设置流的位置 当然要是已经是一次读取7字节了 那就不能再变小了 直接encode吧
247
+ buf_rate = buf_rate / 2
248
+ current_buf_len = buf_rate * 7
249
+ input.seek(-size, 1)
250
+ continue
251
+ chunk_ptr = <const char*>PyBytes_AS_STRING(chunk)
252
+ with nogil:
253
+ count = b14_encode_safe(chunk_ptr, <int>size, output_buf)
254
+ output.write(<bytes>output_buf[:count])
255
+ if size < 7:
256
+ break
257
+ finally:
258
+ PyMem_Free(output_buf)
259
+
154
260
  def decode_file(object input,
155
261
  object output,
156
262
  int32_t buf_rate = 10):
@@ -180,7 +286,7 @@ def decode_file(object input,
180
286
  try:
181
287
  while True:
182
288
  chunk = input.read(current_buf_len) # 8的倍数
183
- size = PyBytes_Size(chunk)
289
+ size = PyBytes_GET_SIZE(chunk)
184
290
  if size == 0:
185
291
  break
186
292
  if <int32_t> size < current_buf_len: # 长度不够了
@@ -190,7 +296,7 @@ def decode_file(object input,
190
296
  input.seek(-size, 1)
191
297
  continue
192
298
  tmp = input.read(2) # type: bytes
193
- if PyBytes_Size(tmp) == 2:
299
+ if PyBytes_GET_SIZE(tmp) == 2:
194
300
  if tmp[0] == 61: # = stream完了 一次解码8n+2个字节
195
301
  chunk += tmp
196
302
  size += 2
@@ -203,6 +309,58 @@ def decode_file(object input,
203
309
  finally:
204
310
  PyMem_Free(output_buf)
205
311
 
312
+ def decode_file_safe(object input,
313
+ object output,
314
+ int32_t buf_rate = 10):
315
+ if not PyFile_Check(input):
316
+ raise TypeError("input except a file-like object, got %s" % type(input).__name__)
317
+ if not PyFile_Check(output):
318
+ raise TypeError("output except a file-like object, got %s" % type(output).__name__)
319
+ if buf_rate <= 0:
320
+ buf_rate = 1
321
+
322
+ chunk = input.read(1) # type: bytes
323
+ if not PyBytes_Check(chunk):
324
+ raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
325
+ if chunk == b"\xfe": # 去头
326
+ input.read(1)
327
+ else:
328
+ input.seek(0, 0) # 没有头 回到开头
329
+
330
+ cdef int32_t current_buf_len = buf_rate * 8
331
+ cdef size_t output_size = <size_t> b14_decode_len(<int> current_buf_len, 0)
332
+ cdef char *output_buf = <char *> PyMem_Malloc(output_size)
333
+ if output_buf == NULL:
334
+ raise MemoryError
335
+ cdef Py_ssize_t size
336
+ cdef int count = 0
337
+ cdef const char *chunk_ptr
338
+ try:
339
+ while True:
340
+ chunk = input.read(current_buf_len) # 8的倍数
341
+ size = PyBytes_GET_SIZE(chunk)
342
+ if size == 0:
343
+ break
344
+ if <int32_t> size < current_buf_len: # 长度不够了
345
+ if buf_rate > 1: # 还能继续变小
346
+ buf_rate = buf_rate / 2 # 重新设置一次读取的大小
347
+ current_buf_len = buf_rate * 8
348
+ input.seek(-size, 1)
349
+ continue
350
+ tmp = input.read(2) # type: bytes
351
+ if PyBytes_GET_SIZE(tmp) == 2:
352
+ if tmp[0] == 61: # = stream完了 一次解码8n+2个字节
353
+ chunk += tmp
354
+ size += 2
355
+ else:
356
+ input.seek(-2, 1)
357
+ chunk_ptr = <const char *> PyBytes_AS_STRING(chunk)
358
+ with nogil:
359
+ count = b14_decode_safe(chunk_ptr, <int> size, output_buf)
360
+ output.write(<bytes>output_buf[:count])
361
+ finally:
362
+ PyMem_Free(output_buf)
363
+
206
364
  cpdef inline bint is_64bits() nogil:
207
365
  return pybase16384_64bits()
208
366
 
@@ -388,3 +546,74 @@ cpdef inline decode_fd_detailed(int inp, int out, int flag):
388
546
  finally:
389
547
  PyMem_Free(encbuf)
390
548
  PyMem_Free(decbuf)
549
+
550
+ # stream
551
+ cdef ssize_t b14_readcallback(const void *client_data, void *buffer, size_t count) except -100 with gil:
552
+ cdef object file = <object>client_data
553
+ cdef bytes data = file.read(count)
554
+ cdef char* data_ptr = PyBytes_AS_STRING(data)
555
+ cdef ssize_t data_size = <ssize_t>PyBytes_GET_SIZE(data)
556
+ memcpy(buffer, data_ptr, <size_t>data_size)
557
+ return data_size
558
+
559
+ cdef ssize_t b14_writecallback(const void *client_data, const void *buffer, size_t count) except -100 with gil:
560
+ cdef object file = <object>client_data
561
+ cdef bytes data = PyBytes_FromStringAndSize(<char*>buffer, <Py_ssize_t>count)
562
+ cdef ssize_t ret = <ssize_t>file.write(data)
563
+ return ret
564
+
565
+ cpdef inline encode_stream_detailed(object inp, object out, int flag):
566
+ cdef char * encbuf = <char *> PyMem_Malloc(<size_t> BASE16384_ENCBUFSZ)
567
+ if encbuf == NULL:
568
+ raise MemoryError
569
+ cdef char * decbuf = <char *> PyMem_Malloc(<size_t> BASE16384_DECBUFSZ)
570
+ if decbuf == NULL:
571
+ PyMem_Free(encbuf)
572
+ raise MemoryError
573
+
574
+ cdef base16384_err_t ret
575
+
576
+ cdef base16384_stream_t inpstream = base16384_stream_t(f=base16384_io_function_t(reader=b14_readcallback),
577
+ client_data=<void *> inp)
578
+ # inpstream.f.reader = b14_readcallback
579
+ # inpstream.client_data = <const void*>inp
580
+
581
+ cdef base16384_stream_t outstream = base16384_stream_t(f=base16384_io_function_t(writer=b14_writecallback),
582
+ client_data=<void *> out)
583
+ # outstream.f.writer = b14_writecallback
584
+ # outstream.client_data = <const void*>out
585
+ try:
586
+ with nogil:
587
+ ret = b14_encode_stream_detailed(&inpstream, &outstream, encbuf, decbuf, flag)
588
+ if ret != base16384_err_ok:
589
+ raise ValueError(err_to_str(ret))
590
+ finally:
591
+ PyMem_Free(encbuf)
592
+ PyMem_Free(decbuf)
593
+
594
+ cpdef inline decode_stream_detailed(object inp, object out, int flag):
595
+ cdef char * encbuf = <char *> PyMem_Malloc(<size_t> BASE16384_ENCBUFSZ)
596
+ if encbuf == NULL:
597
+ raise MemoryError
598
+ cdef char * decbuf = <char *> PyMem_Malloc(<size_t> BASE16384_DECBUFSZ)
599
+ if decbuf == NULL:
600
+ PyMem_Free(encbuf)
601
+ raise MemoryError
602
+
603
+ cdef base16384_err_t ret
604
+
605
+ cdef base16384_stream_t inpstream = base16384_stream_t(f=base16384_io_function_t(reader=b14_readcallback),client_data= <void*>inp)
606
+ # inpstream.f.reader = b14_readcallback
607
+ # inpstream.client_data = <const void*>inp
608
+
609
+ cdef base16384_stream_t outstream = base16384_stream_t(f=base16384_io_function_t(writer=b14_writecallback),client_data= <void*>out)
610
+ # outstream.f.writer = b14_writecallback
611
+ # outstream.client_data = <const void*>out
612
+ try:
613
+ with nogil:
614
+ ret = b14_decode_stream_detailed(&inpstream, &outstream, encbuf, decbuf, flag)
615
+ if ret != base16384_err_ok:
616
+ raise ValueError(err_to_str(ret))
617
+ finally:
618
+ PyMem_Free(encbuf)
619
+ PyMem_Free(decbuf)
@@ -10,7 +10,7 @@ cdef extern from "base16384.h" nogil:
10
10
 
11
11
  int BASE16384_FLAG_NOHEADER
12
12
  int BASE16384_FLAG_SUM_CHECK_ON_REMAIN
13
- int BASE16384_SIMPLE_SUM_INIT_VALUE
13
+ int BASE16384_FLAG_DO_SUM_CHECK_FORCELY
14
14
 
15
15
  ctypedef enum base16384_err_t:
16
16
  base16384_err_ok
@@ -29,11 +29,14 @@ cdef extern from "base16384.h" nogil:
29
29
  # decode_len calc min buf size to fill decode result
30
30
  int b14_decode_len "base16384_decode_len" (int dlen, int offset)
31
31
 
32
+ int b14_encode_safe "base16384_encode_safe" (const char * data, int dlen, char * buf)
32
33
  # encode data and write result into buf
33
34
  int b14_encode "base16384_encode" (const char* data, int dlen, char* buf)
34
35
 
35
36
  int b14_encode_unsafe "base16384_encode_unsafe" (const char * data, int dlen, char * buf)
36
37
  # decode data and write result into buf
38
+ int b14_decode_safe "base16384_decode_safe" (const char * data, int dlen, char * buf)
39
+
37
40
  int b14_decode "base16384_decode" (const char* data, int dlen, char* buf)
38
41
 
39
42
  int b14_decode_unsafe "base16384_decode_unsafe"(const char * data, int dlen, char * buf)
@@ -82,14 +85,29 @@ cdef extern from "base16384.h" nogil:
82
85
  # base16384_decode_fd_detailed decodes input fd to output fd.
83
86
  # encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
84
87
  base16384_err_t b14_decode_fd_detailed "base16384_decode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
88
+ # stream
89
+ ctypedef ssize_t (*base16384_reader_t) (const void *client_data, void *buffer, size_t count) except -100
90
+ ctypedef ssize_t (*base16384_writer_t) (const void *client_data, const void *buffer, size_t count) except -100
91
+
92
+ ctypedef union base16384_io_function_t:
93
+ base16384_reader_t reader
94
+ base16384_writer_t writer
95
+
96
+ ctypedef struct base16384_stream_t:
97
+ base16384_io_function_t f
98
+ void* client_data
85
99
 
100
+ base16384_err_t b14_encode_stream "base16384_encode_stream"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf)
101
+ base16384_err_t b14_encode_stream_detailed "base16384_encode_stream_detailed"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf, int flag)
102
+ base16384_err_t b14_decode_stream "base16384_decode_stream"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf)
103
+ base16384_err_t b14_decode_stream_detailed "base16384_decode_stream_detailed"(base16384_stream_t* input, base16384_stream_t* output, char* encbuf, char* decbuf, int flag)
86
104
 
87
105
  cdef extern from * nogil:
88
106
  """
89
107
  #ifdef CPUBIT32
90
- #define pybase16384_64bits() 0
108
+ #define pybase16384_64bits() (0)
91
109
  #else
92
- #define pybase16384_64bits() 1
110
+ #define pybase16384_64bits() (1)
93
111
  #endif
94
112
  """
95
113
  int32_t pybase16384_64bits()
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pybase16384
3
- Version: 0.3.6
3
+ Version: 0.3.8
4
4
  Summary: fast base16384 encode and decode
5
5
  Home-page: https://github.com/synodriver/pybase16384
6
6
  Author: synodriver
@@ -24,7 +24,18 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
24
24
  Requires-Python: >=3.6
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
- Requires-Dist: cffi (>=1.0.0)
27
+ Requires-Dist: cffi>=1.0.0
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license
36
+ Dynamic: requires-dist
37
+ Dynamic: requires-python
38
+ Dynamic: summary
28
39
 
29
40
  <h1 align="center"><i>✨ pybase16384 ✨ </i></h1>
30
41
 
@@ -78,37 +89,81 @@ for i in range(1):
78
89
 
79
90
  ### 公开函数
80
91
  ```python
92
+ from typing import IO
93
+
81
94
  def encode_len(dlen: int) -> int: ...
82
95
 
83
96
  def decode_len(dlen: int, offset: int) -> int: ...
84
97
 
98
+ ENCBUFSZ: int
99
+ DECBUFSZ: int
100
+ FLAG_NOHEADER: int
101
+ FLAG_SUM_CHECK_ON_REMAIN: int
102
+ FLAG_DO_SUM_CHECK_FORCELY: int
103
+
104
+ def is_64bits() -> bool: ...
105
+
106
+ def encode_file(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
107
+
108
+ def encode_file_safe(input: IO, output: IO, write_head: bool = ..., buf_rate: int = ...): ...
109
+
110
+ def decode_file(input: IO, output: IO, buf_rate: int = ...): ...
111
+
112
+ def decode_file_safe(input: IO, output: IO, buf_rate: int = ...): ...
113
+
114
+ def ensure_bytes(inp) -> bytes: ...
115
+
116
+ def encode_local_file(inp, out) -> None: ...
117
+
118
+ def decode_local_file(inp, out) -> None: ...
119
+
120
+ def encode_fd(inp: int, out: int) -> None: ...
121
+
122
+ def decode_fd(inp: int, out: int) -> None: ...
123
+
124
+ def encode_local_file_detailed(inp, out, flag: int) -> None: ...
125
+
126
+ def decode_local_file_detailed(inp, out, flag: int) -> None: ...
127
+
128
+ def encode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
129
+
130
+ def decode_fd_detailed(inp: int, out: int, flag: int) -> None: ...
131
+
85
132
  def encode(data: bytes) -> bytes: ...
86
133
 
134
+ def encode_safe(data: bytes) -> bytes: ...
135
+
87
136
  def decode(data: bytes) -> bytes: ...
88
137
 
89
- def decode_file(input: BinaryIO, output: BinaryIO, buf_rate: int = 10) -> None: ...
138
+ def decode_safe(data: bytes) -> bytes: ...
90
139
 
91
- def encode_file(input: BinaryIO, output: BinaryIO, boolwrite_head: bool = False, buf_rate: int = 10) -> None: ...
140
+ def encode_from_string(data: str, write_head: bool = ...) -> bytes: ...
92
141
 
93
- def encode_from_string(data: str, write_head: bool = False) -> bytes: ...
142
+ def encode_from_string_safe(data: str, write_head: bool = ...) -> bytes: ...
94
143
 
95
144
  def encode_to_string(data: bytes) -> str: ...
96
145
 
146
+ def encode_to_string_safe(data: bytes) -> str: ...
147
+
97
148
  def encode_string(data: str) -> str: ...
98
149
 
150
+ def encode_string_safe(data: str) -> str: ...
151
+
99
152
  def decode_from_bytes(data: bytes) -> str: ...
100
153
 
154
+ def decode_from_bytes_safe(data: bytes) -> str: ...
155
+
101
156
  def decode_from_string(data: str) -> bytes: ...
102
157
 
158
+ def decode_from_string_safe(data: str) -> bytes: ...
159
+
103
160
  def decode_string(data: str) -> str: ...
104
161
 
105
- def encode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
162
+ def decode_string_safe(data: str) -> str: ...
106
163
 
107
- def decode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
164
+ def encode_stream_detailed(inp, out, flag: int): ...
108
165
 
109
- def encode_fd(inp: int, out: int) -> None: ...
110
-
111
- def decode_fd(inp: int, out: int) -> None: ...
166
+ def decode_stream_detailed(inp, out, flag: int): ...
112
167
  ```
113
168
  - write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
114
169
 
@@ -124,12 +179,20 @@ def decode_fd(inp: int, out: int) -> None: ...
124
179
  ```python
125
180
  def _encode(data: BufferProtocol) -> bytes: ...
126
181
 
182
+ def _encode_safe(data: BufferProtocol) -> bytes: ...
183
+
127
184
  def _decode(data: BufferProtocol) -> bytes: ...
128
185
 
186
+ def _decode_safe(data: BufferProtocol) -> bytes: ...
187
+
129
188
  def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
130
189
 
190
+ def _encode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
191
+
131
192
  def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
132
193
 
194
+ def _decode_into_safe(data: BufferProtocol, dest: BufferProtocol) -> int: ...
195
+
133
196
  def is_64bits() -> bool: ...
134
197
  ```
135
198
  - ```_decode```在解码```b'='```开头的数据时***不安全***:***解释器异常***
@@ -0,0 +1,16 @@
1
+ pybase16384/__init__.py,sha256=4Mj19dGl2Zp410wwBJLI6kNx1PWHwTJEO4BNLHBR3So,5102
2
+ pybase16384/backends/__init__.py,sha256=9aG9WOI42Hcgaj9QGw99OIvKZTG-sYNlLBUctorc4Kg,56
3
+ pybase16384/backends/cffi/__init__.py,sha256=smNNdEBXVWuj1eaWVW8xa5kuhiS4QjOyXLKLro042qU,16433
4
+ pybase16384/backends/cffi/_core.pyd,sha256=IJER1uyEWyTyG3XDJl_h1QoGRvr6g4XQ_jOMWsPNxaE,47104
5
+ pybase16384/backends/cffi/build.py,sha256=GOtD0hkrZsJNbYi54-ianETrHU4U8JA_QlbLdgPoaQw,6007
6
+ pybase16384/backends/cython/__init__.py,sha256=J5xLqqeKbytQioY6KaXA8xEDWzOTE6twDKEo-1j0Tzk,774
7
+ pybase16384/backends/cython/_core.c,sha256=IpplvkxB9-dTVgNR0pyWo_evsTkQdwJ7QjOIfPzLzBo,1598430
8
+ pybase16384/backends/cython/_core.pxi,sha256=SPgwG7QKofRYdJDRrhx2TWRvOuBuwTjRGg2WvGUrQw4,542
9
+ pybase16384/backends/cython/_core.pyd,sha256=S5dcELkFjX2v1B8nH2BGH0ckcoarmc94C33MpcmjRRU,208384
10
+ pybase16384/backends/cython/_core.pyx,sha256=wbONqAMbaH2HnRtI0gl6L3wJtqKQarnV_Be71vbHSjU,25778
11
+ pybase16384/backends/cython/base16384.pxd,sha256=XHdCpT6FfJXEhFpoQ2rbf_b4hAbQ16DeKm-BqPQU8us,6055
12
+ pybase16384-0.3.8.dist-info/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
13
+ pybase16384-0.3.8.dist-info/METADATA,sha256=nLISMOQhcn7yICtXL11vuil7b7rhnABh-rjKYZnh1K4,7051
14
+ pybase16384-0.3.8.dist-info/WHEEL,sha256=agy-BJge3afXwWznUXANATmKFW4eqelqRR0uf608A_0,99
15
+ pybase16384-0.3.8.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
16
+ pybase16384-0.3.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-cp39-win_amd64
5
5
 
@@ -1,16 +0,0 @@
1
- pybase16384/__init__.py,sha256=ORhQHbG_JSqXq78YxjIaWxJpSzv84TVS7rgd2wQKpS0,3062
2
- pybase16384/backends/__init__.py,sha256=9aG9WOI42Hcgaj9QGw99OIvKZTG-sYNlLBUctorc4Kg,56
3
- pybase16384/backends/cffi/__init__.py,sha256=5Uk7Il3xmAkj9HxhbB1OdXE2Cslc0rDuIYcfDrLQcug,9774
4
- pybase16384/backends/cffi/_core.pyd,sha256=AtwuwRLw_MbW7pqyUzaEU6aYmLlTz81e-SFv9hehXQE,37888
5
- pybase16384/backends/cffi/build.py,sha256=DXOVlPcnnjNFt11n3TSeiMd5OUbdcm3bbylDQppy-mo,4539
6
- pybase16384/backends/cython/__init__.py,sha256=b3qH9k-e72aqwxdZHfR-PipQNzvBFGWq9uiX6v_PfuI,578
7
- pybase16384/backends/cython/_core.c,sha256=7WXWJg1wJV3E7rMLUsfmSFPdNW7zvMJ6uic7H_zEiTM,1393181
8
- pybase16384/backends/cython/_core.pxi,sha256=SPgwG7QKofRYdJDRrhx2TWRvOuBuwTjRGg2WvGUrQw4,542
9
- pybase16384/backends/cython/_core.pyd,sha256=fA6p6JOmji_dJxeBHyakWJsow9OCGiARu8OrU3A7i0o,192000
10
- pybase16384/backends/cython/_core.pyx,sha256=mWb4dr-hEjp1QPI37mU_lyJyUohHYxacCPyPbmAjP5U,15765
11
- pybase16384/backends/cython/base16384.pxd,sha256=ZIOMla80PKuWAIUZIFsJh4b7rzjfHxxaa-VEQ9CQe5E,4749
12
- pybase16384-0.3.6.dist-info/LICENSE,sha256=gcuuhKKc5-dwvyvHsXjlC9oM6N5gZ6umYbC8ewW1Yvg,35821
13
- pybase16384-0.3.6.dist-info/METADATA,sha256=ASRzCwkCUBoHKlPqlv1GT5P1dNjhILV4Yetdp4oM_w8,5539
14
- pybase16384-0.3.6.dist-info/WHEEL,sha256=eep6QWEFiQfg2wcclssb_WY-D33AnLYLnEKGA9Rn-VU,100
15
- pybase16384-0.3.6.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
16
- pybase16384-0.3.6.dist-info/RECORD,,