pybase16384 0.3.7__cp310-cp310-macosx_10_9_universal2.whl → 0.3.8__cp310-cp310-macosx_10_9_universal2.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.
- pybase16384/__init__.py +5 -1
- pybase16384/backends/cffi/__init__.py +76 -6
- pybase16384/backends/cffi/_core.abi3.so +0 -0
- pybase16384/backends/cffi/build.py +39 -1
- pybase16384/backends/cython/__init__.py +3 -0
- pybase16384/backends/cython/_core.abi3.so +0 -0
- pybase16384/backends/cython/_core.c +9997 -9909
- pybase16384/backends/cython/_core.pyx +87 -11
- pybase16384/backends/cython/base16384.pxd +16 -1
- {pybase16384-0.3.7.dist-info → pybase16384-0.3.8.dist-info}/METADATA +18 -3
- pybase16384-0.3.8.dist-info/RECORD +16 -0
- {pybase16384-0.3.7.dist-info → pybase16384-0.3.8.dist-info}/WHEEL +1 -1
- pybase16384-0.3.7.dist-info/RECORD +0 -16
- {pybase16384-0.3.7.dist-info → pybase16384-0.3.8.dist-info}/LICENSE +0 -0
- {pybase16384-0.3.7.dist-info → pybase16384-0.3.8.dist-info}/top_level.txt +0 -0
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
# cython: language_level=3
|
|
2
2
|
# cython: cdivision=True
|
|
3
|
-
from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_Check,
|
|
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
11
|
BASE16384_DECBUFSZ, BASE16384_ENCBUFSZ,
|
|
10
12
|
BASE16384_FLAG_DO_SUM_CHECK_FORCELY, BASE16384_FLAG_NOHEADER,
|
|
11
13
|
BASE16384_FLAG_SUM_CHECK_ON_REMAIN, b14_decode, b14_decode_fd,
|
|
12
14
|
b14_decode_fd_detailed, b14_decode_file, b14_decode_file_detailed,
|
|
13
|
-
b14_decode_len, b14_decode_safe,
|
|
15
|
+
b14_decode_len, b14_decode_safe, b14_decode_stream,
|
|
16
|
+
b14_decode_stream_detailed, b14_encode, b14_encode_fd,
|
|
14
17
|
b14_encode_fd_detailed, b14_encode_file, b14_encode_file_detailed,
|
|
15
|
-
b14_encode_len, b14_encode_safe,
|
|
18
|
+
b14_encode_len, b14_encode_safe, b14_encode_stream,
|
|
19
|
+
b14_encode_stream_detailed, base16384_err_fopen_input_file,
|
|
16
20
|
base16384_err_fopen_output_file, base16384_err_get_file_size,
|
|
17
21
|
base16384_err_invalid_commandline_parameter,
|
|
18
22
|
base16384_err_invalid_decoding_checksum, base16384_err_invalid_file_name,
|
|
19
23
|
base16384_err_map_input_file, base16384_err_ok,
|
|
20
24
|
base16384_err_open_input_file, base16384_err_read_file, base16384_err_t,
|
|
21
|
-
base16384_err_write_file,
|
|
25
|
+
base16384_err_write_file, base16384_io_function_t, base16384_stream_t,
|
|
26
|
+
pybase16384_64bits)
|
|
22
27
|
|
|
23
28
|
from pathlib import Path
|
|
24
29
|
|
|
@@ -189,7 +194,7 @@ def encode_file(object input,
|
|
|
189
194
|
first_check = 0
|
|
190
195
|
if not PyBytes_Check(chunk):
|
|
191
196
|
raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
|
|
192
|
-
size =
|
|
197
|
+
size = PyBytes_GET_SIZE(chunk)
|
|
193
198
|
if <int32_t> size < current_buf_len: # 数据不够了 要减小一次读取的量
|
|
194
199
|
if buf_rate > 1: # 重新设置一次读取的大小 重新设置流的位置 当然要是已经是一次读取7字节了 那就不能再变小了 直接encode吧
|
|
195
200
|
buf_rate = buf_rate / 2
|
|
@@ -236,7 +241,7 @@ def encode_file_safe(object input,
|
|
|
236
241
|
first_check = 0
|
|
237
242
|
if not PyBytes_Check(chunk):
|
|
238
243
|
raise TypeError(f"input must be a file-like rb object, got {type(input).__name__}")
|
|
239
|
-
size =
|
|
244
|
+
size = PyBytes_GET_SIZE(chunk)
|
|
240
245
|
if <int32_t> size < current_buf_len: # 数据不够了 要减小一次读取的量
|
|
241
246
|
if buf_rate > 1: # 重新设置一次读取的大小 重新设置流的位置 当然要是已经是一次读取7字节了 那就不能再变小了 直接encode吧
|
|
242
247
|
buf_rate = buf_rate / 2
|
|
@@ -281,7 +286,7 @@ def decode_file(object input,
|
|
|
281
286
|
try:
|
|
282
287
|
while True:
|
|
283
288
|
chunk = input.read(current_buf_len) # 8的倍数
|
|
284
|
-
size =
|
|
289
|
+
size = PyBytes_GET_SIZE(chunk)
|
|
285
290
|
if size == 0:
|
|
286
291
|
break
|
|
287
292
|
if <int32_t> size < current_buf_len: # 长度不够了
|
|
@@ -291,7 +296,7 @@ def decode_file(object input,
|
|
|
291
296
|
input.seek(-size, 1)
|
|
292
297
|
continue
|
|
293
298
|
tmp = input.read(2) # type: bytes
|
|
294
|
-
if
|
|
299
|
+
if PyBytes_GET_SIZE(tmp) == 2:
|
|
295
300
|
if tmp[0] == 61: # = stream完了 一次解码8n+2个字节
|
|
296
301
|
chunk += tmp
|
|
297
302
|
size += 2
|
|
@@ -333,7 +338,7 @@ def decode_file_safe(object input,
|
|
|
333
338
|
try:
|
|
334
339
|
while True:
|
|
335
340
|
chunk = input.read(current_buf_len) # 8的倍数
|
|
336
|
-
size =
|
|
341
|
+
size = PyBytes_GET_SIZE(chunk)
|
|
337
342
|
if size == 0:
|
|
338
343
|
break
|
|
339
344
|
if <int32_t> size < current_buf_len: # 长度不够了
|
|
@@ -343,7 +348,7 @@ def decode_file_safe(object input,
|
|
|
343
348
|
input.seek(-size, 1)
|
|
344
349
|
continue
|
|
345
350
|
tmp = input.read(2) # type: bytes
|
|
346
|
-
if
|
|
351
|
+
if PyBytes_GET_SIZE(tmp) == 2:
|
|
347
352
|
if tmp[0] == 61: # = stream完了 一次解码8n+2个字节
|
|
348
353
|
chunk += tmp
|
|
349
354
|
size += 2
|
|
@@ -541,3 +546,74 @@ cpdef inline decode_fd_detailed(int inp, int out, int flag):
|
|
|
541
546
|
finally:
|
|
542
547
|
PyMem_Free(encbuf)
|
|
543
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)
|
|
@@ -85,7 +85,22 @@ cdef extern from "base16384.h" nogil:
|
|
|
85
85
|
# base16384_decode_fd_detailed decodes input fd to output fd.
|
|
86
86
|
# encbuf & decbuf must be no less than BASE16384_ENCBUFSZ & BASE16384_DECBUFSZ
|
|
87
87
|
base16384_err_t b14_decode_fd_detailed "base16384_decode_fd_detailed" (int input, int output, char* encbuf, char* decbuf, int flag)
|
|
88
|
-
|
|
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
|
|
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)
|
|
89
104
|
|
|
90
105
|
cdef extern from * nogil:
|
|
91
106
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: pybase16384
|
|
3
|
-
Version: 0.3.
|
|
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
|
|
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
|
|
|
@@ -149,6 +160,10 @@ def decode_from_string_safe(data: str) -> bytes: ...
|
|
|
149
160
|
def decode_string(data: str) -> str: ...
|
|
150
161
|
|
|
151
162
|
def decode_string_safe(data: str) -> str: ...
|
|
163
|
+
|
|
164
|
+
def encode_stream_detailed(inp, out, flag: int): ...
|
|
165
|
+
|
|
166
|
+
def decode_stream_detailed(inp, out, flag: int): ...
|
|
152
167
|
```
|
|
153
168
|
- write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
|
|
154
169
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pybase16384/__init__.py,sha256=xDOQ59rGsfkEhlODtzpqltiJmvTOMYT0puEhW6w8DBo,4897
|
|
2
|
+
pybase16384/backends/__init__.py,sha256=vdW_t1O2WNfdRmxDlEXRvTpyJj5ufKWAUsD2fbtku5g,55
|
|
3
|
+
pybase16384/backends/cffi/build.py,sha256=NyTK_W4JKJbqtdAS0yZ0sxkQvLDE8npjOskWN1-YOqk,5824
|
|
4
|
+
pybase16384/backends/cffi/__init__.py,sha256=oGen7JI3AMlvsCjM8xF4k6zBK2v_QqQ5UsrdMVtD_Zo,15970
|
|
5
|
+
pybase16384/backends/cffi/_core.abi3.so,sha256=t5zvjFeo68fo2WMTMI2F9leH9WR8zITIx-rfkV3cimM,188768
|
|
6
|
+
pybase16384/backends/cython/_core.c,sha256=Co0qxbDmNKtX39tTxGMB2Sh5zYdExvPFvUeGVq3X5C8,1558557
|
|
7
|
+
pybase16384/backends/cython/__init__.py,sha256=iqaf2DeavB1x_LnQi949Qqkrn00KAwG9xJMPVUdnIB8,738
|
|
8
|
+
pybase16384/backends/cython/base16384.pxd,sha256=HFGuEe2rXBWYw1vx74uaI7YATtkRGpcUAjANMRxPRFA,5942
|
|
9
|
+
pybase16384/backends/cython/_core.abi3.so,sha256=yc-8MKudPApaHtGSj2so5AQvhCgYW6zqe9HKeoHMk_w,527760
|
|
10
|
+
pybase16384/backends/cython/_core.pyx,sha256=OcY07Gk5n-9snqRCFrVTU-WhI8k1yiD6zcutRD5G1Dk,25159
|
|
11
|
+
pybase16384/backends/cython/_core.pxi,sha256=2fXuRiumLqxO0bnmZVEz0lr_GX-grJGBfhGIVedfyt8,530
|
|
12
|
+
pybase16384-0.3.8.dist-info/RECORD,,
|
|
13
|
+
pybase16384-0.3.8.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
14
|
+
pybase16384-0.3.8.dist-info/WHEEL,sha256=Yd3eJSBM2hj8W-ouaiMfFUwQYAS-D6P73Ob9yN5MZd0,114
|
|
15
|
+
pybase16384-0.3.8.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
|
|
16
|
+
pybase16384-0.3.8.dist-info/METADATA,sha256=HKwiEO0_m8J4u1QmjLLz1c2j2ymgAgh4eNZJ58t_frA,6836
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
pybase16384-0.3.7.dist-info/RECORD,,
|
|
2
|
-
pybase16384-0.3.7.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
3
|
-
pybase16384-0.3.7.dist-info/WHEEL,sha256=IgnQe-3f5zUKNlfG9a78AmcEZfnjZ7r4JD-upganVCQ,115
|
|
4
|
-
pybase16384-0.3.7.dist-info/top_level.txt,sha256=kXpl7pWjnjpm74qJP0SJg3JhbiWuwKQApJgkJH0B5Mk,12
|
|
5
|
-
pybase16384-0.3.7.dist-info/METADATA,sha256=t825ZkNAE5A1iDixOyZMIslruzLo4skUHaS7VcFauwY,6499
|
|
6
|
-
pybase16384/__init__.py,sha256=iPZOUFmVvcd6syd2zK7MHEcw8c4OksXMEnZX3m8dXrw,4769
|
|
7
|
-
pybase16384/backends/__init__.py,sha256=vdW_t1O2WNfdRmxDlEXRvTpyJj5ufKWAUsD2fbtku5g,55
|
|
8
|
-
pybase16384/backends/cffi/build.py,sha256=uoF5uBdRbIsWw6TxBcdpvDy9HxgfrG7KukLuLb44tXk,4548
|
|
9
|
-
pybase16384/backends/cffi/__init__.py,sha256=AJbC3SW14ojHLtrkyCSaVVQ-ScfRxOiCFVQSVgQi2F8,14058
|
|
10
|
-
pybase16384/backends/cffi/_core.abi3.so,sha256=oxs2xO0kqtkukA-ZuMVAyWc9Tmk1SHVTKFN8JDKs6iM,154848
|
|
11
|
-
pybase16384/backends/cython/_core.c,sha256=6m0GPP27bApdrFuE9szniYP9ezBGOH7pwYISlLv7hTw,1538902
|
|
12
|
-
pybase16384/backends/cython/__init__.py,sha256=4I6QVQclKorVEe4BlSx_9HfgDf9yTdHMU7w9-g-t6tU,681
|
|
13
|
-
pybase16384/backends/cython/base16384.pxd,sha256=zZDthlWUJY_7hq4Fs2X3JcWJ_lcsh0Gce4nZ-ejG8dY,4843
|
|
14
|
-
pybase16384/backends/cython/_core.abi3.so,sha256=bJdvby_rqJUfwdVcry6aJtSVdLpdUmXEZ4T3Zy0gmQo,558704
|
|
15
|
-
pybase16384/backends/cython/_core.pyx,sha256=4zCEfDCLww4_0UvTkTbiQ0CyXqm91CnlTFdo1SOeu9M,21871
|
|
16
|
-
pybase16384/backends/cython/_core.pxi,sha256=2fXuRiumLqxO0bnmZVEz0lr_GX-grJGBfhGIVedfyt8,530
|
|
File without changes
|
|
File without changes
|