base16384 encode and decode
Project description
✨ pybase16384 ✨
The python binding for base16384
一种神奇的编码
使用
- 编码/解码文本
>>> import pybase16384 as pybs
>>> pybs.encode_string('hello!!')
'栙擆羼漡'
>>> pybs.decode_string('栙擆羼漡')
'hello!!'
- 编码文件
from io import BytesIO
import pybase16384 as pybs
with open("input.pcm", "rb") as f:
data = f.read()
for i in range(1):
pybs.encode_file(BytesIO(data), open("output2.pcm", 'wb'), True)
- 解码文件
from io import BytesIO
import pybase16384 as pybs
with open("output2.pcm", "rb") as f:
data = f.read()
for i in range(1):
pybs.decode_file(BytesIO(data), open("input2.pcm", 'wb'))
公开函数
def encode_len(dlen: int) -> int: ...
def decode_len(dlen: int, offset: int) -> int: ...
def encode(data: bytes) -> bytes: ...
def decode(data: bytes) -> bytes: ...
def decode_file(input: BinaryIO, output: BinaryIO, buf_rate: int = 10) -> None: ...
def encode_file(input: BinaryIO, output: BinaryIO, boolwrite_head: bool = False, buf_rate: int = 10) -> None: ...
def encode_from_string(data: str, write_head: bool = False) -> bytes: ...
def encode_to_string(data: bytes) -> str: ...
def encode_string(data: str) -> str: ...
def decode_from_bytes(data: bytes) -> str: ...
def decode_from_string(data: str) -> bytes: ...
def decode_string(data: str) -> str: ...
-
write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。
-
buf_rate指定读取文件的策略。当它为n时,则表示一次读取7n或者8n个字节。如果读到的字节长度小于预期,则说明长度不够, 此时,n将减半,恢复文件指针,重新读取。如果当n=1时长度仍然不够,就地encode/decode处理之。
-
encode_len
和decode_len
用于计算输出的长度
内部函数
- 他们直接来自底层的C库,高性能,但是一般不需要在外部使用(除非是增加性能)
def _encode(data: BufferProtocol) -> bytes: ...
def _decode(data: BufferProtocol) -> bytes: ...
def _encode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
def _decode_into(data: BufferProtocol, dest: BufferProtocol) -> int: ...
def is_64bits() -> bool: ...
_decode
在解码b'='
开头的数据时不安全:解释器异常_encode_into
和_decode_into
直接操作缓冲区对象的底层指针,0拷贝,当然也和上面一样的问题,他们是没有检查的
✨ v0.3更新 ✨
融合了 CFFI 版本的成果,现在一个包可以同时在cpython和pypy上运行
本机编译
python -m pip install setuptools wheel cython cffi
git clone https://github.com/synodriver/pybase16384
cd pybase16384
git submodule update --init --recursive
python setup.py bdist_wheel --use-cython --use-cffi
后端选择
默认由py实现决定,在cpython上自动选择cython后端,在pypy上自动选择cffi后端,使用B14_USE_CFFI
环境变量可以强制选择cffi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pybase16384-0.3.0.tar.gz
(164.0 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.3.0-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1fe55d15f6a71044408a418ddfe84e5ae1f1a3d08646968b1140a3fe3b26720 |
|
MD5 | 6b1b995b99fe7bcb27a568592b1e7c69 |
|
BLAKE2b-256 | cab8f5fc0e8e91e80c4af65e5170bf23152023e99e2fa451848be1bc93580c7d |
Close
Hashes for pybase16384-0.3.0-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0feca7cd89b19c10632820e5e7266c90e2b7d3d1080da4def3b055ec7cb916b |
|
MD5 | e146ff27af21050391fc46eec71c5aeb |
|
BLAKE2b-256 | 70e3d5850f9681806edfbfe35095d6a9db7d4a2623c7b479f609bed47e2437a6 |
Close
Hashes for pybase16384-0.3.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a797a6d7e106fb2544c0c905681f337313ffaa8cac08dad4a512796399241649 |
|
MD5 | 3bd60d667ea818dbb3ec98b473084b29 |
|
BLAKE2b-256 | d10162506a7de5bdab64c5de3aac0a937df92f47984acfd41f5301141a56ffab |
Close
Hashes for pybase16384-0.3.0-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd9fd1a7987472888d3eb81f4af1f0375169de257851cca2d134e552edb9aa73 |
|
MD5 | 135078e8b0038854e6dac2f901be7d2e |
|
BLAKE2b-256 | 21360b6ef88a99a61ac9e7a162af4499cb2763586f0032ec1fd31966f55b1df3 |
Close
Hashes for pybase16384-0.3.0-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 558259d2c41d50474cb2e882e1bf70d25d7e7fdf4e1609e366ad6a40a625f19e |
|
MD5 | bacff98d176eb27d0aae6a1493ac1860 |
|
BLAKE2b-256 | 3ef42007e452ba2c750e073e1047d7d0a995fef02099741e926285f04aa5f5a8 |
Close
Hashes for pybase16384-0.3.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de7763ddc2d425faeb6c7dff0bfc1d7df37c73821d3ec143294cbf8ff8a29444 |
|
MD5 | e0a8631658e41a53c69cca3ba09af516 |
|
BLAKE2b-256 | 9e8edaa7829fecbce148d9fccbf5f50af8ec3411f8ea01428c77a412c24944c3 |
Close
Hashes for pybase16384-0.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bdacbefaf03c053c6a8946e7625c5d47dc1a2c06c399fee8b6fe4e45caf6ea7 |
|
MD5 | 64ed8d5504c6b69adb199f8dcd4041d1 |
|
BLAKE2b-256 | df9576be0eb0df833d64800ab56e0ffd43f706c2e07a999aaefd669610583ebc |
Close
Hashes for pybase16384-0.3.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbc0838f7548a6ac96fd2e2c767a16ac3b99268aa9842ec021db24c28285c905 |
|
MD5 | dcbe11a17f6cf0b16860f6b8b6ee28aa |
|
BLAKE2b-256 | cf5581a041dabd275b0a179a60708a1aac60c80c9eca58936f0bbde198a3a7a7 |
Close
Hashes for pybase16384-0.3.0-cp310-cp310-macosx_10_15_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d7812de5412730fcf2e8fc733530db4eb17f0675cd0009a7c0172f6ed4bd157 |
|
MD5 | 442628acd87ad2303e144bcd4f3fc143 |
|
BLAKE2b-256 | ecef983846ea71c47fbce71bde2eafbdfdce2e4f34b8b32a6e8e10c750d906ea |
Close
Hashes for pybase16384-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6bf150f1f67eae9d2589820ee8707599a6562799dd8c4fa206e1645770ea28e |
|
MD5 | 065a1147a9d87192faebfd9619521a39 |
|
BLAKE2b-256 | a19103bb126517ea6c8d2d66120df2787056e05e2f147c3122b63a6807a0c098 |
Close
Hashes for pybase16384-0.3.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb98e3b07b2b95beb61eeda44313505a199a5bfb2c59fa7af75e597799f5d94 |
|
MD5 | 043afe4fe8584bd1a149b14832cb7bda |
|
BLAKE2b-256 | 750c0586c22190400bf9c250d1166d18e6d0d84cfad77865b0d88c028d876f2b |
Close
Hashes for pybase16384-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45fa7c14f9ba9ab95a58ac61decd379061128273fa93d64fb6fa912d4a2bb3b9 |
|
MD5 | f2d7c4635139748ad1069b9a541d4f8d |
|
BLAKE2b-256 | e204abc73176d1c00d1982801c715846079aa42e8b6ecf541be73dddf99dc59e |
Close
Hashes for pybase16384-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42116810e24049a8af7882f26174367560369189ff718f12eb08a9bd03314c5 |
|
MD5 | 9c503b40649ab3de5be26d0c4f6c2ce8 |
|
BLAKE2b-256 | 8596856260298675485d686067008024d4372f62d4ab0a26be672f22abbea25a |
Close
Hashes for pybase16384-0.3.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e2cd2b2122debf2865d5ee7ef84b64ec0262746546644dcc2a06b7077908fa2 |
|
MD5 | aa7ef674597b86891d281d0de498533f |
|
BLAKE2b-256 | 35bba452d2862007cfbd15db85bd4c26d792060fa379f1ded17217be75b49658 |
Close
Hashes for pybase16384-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fca3d4c8f45093409f2bd6b2e02d4fd3a1f6e8e30fd89213486f868cc7d75444 |
|
MD5 | 9dd94085bc664b888b8dd3876a445acc |
|
BLAKE2b-256 | 0b9eb0367da2f994dd209a70f74cfad758d64e44fadba57ed3bc26bcaa355422 |
Close
Hashes for pybase16384-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7f27367ebf8498d4396b73376fccc6fd51cd5b75f5363f2cc83ded49f531abd |
|
MD5 | 7d9d675299a457be7522aa49ff9b5be5 |
|
BLAKE2b-256 | 0ec66bcd3d7fa52937baa40c1efd0c27bbed4ff7b8845801e68ce412a7f77e86 |
Close
Hashes for pybase16384-0.3.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 834c8268be9382abf2630b38d05c9ef5c2bb3a42f902eff6b372a1ea4b6e5f18 |
|
MD5 | 076f1cecdf5955f299155ca867d51f83 |
|
BLAKE2b-256 | 4d24fa2441704839143bff6983ed54db2e0ef6b80f7a627668d15d0123f36793 |
Close
Hashes for pybase16384-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce20c020e6b58e39126ef1834c950d638ebd5d24cd8efcb0bb926295e637a812 |
|
MD5 | 40d2411a3d81aa1d4ffa37c83f2ca42e |
|
BLAKE2b-256 | 309e51a71815d5e4f5b736c87b4b08f96f29fa22ef341f0c9315c352f3380d79 |
Close
Hashes for pybase16384-0.3.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97506bedbdd9534bd10150db7c8766cf35b29a1ea75f84c36a5d3b9758fff7bd |
|
MD5 | 74684d130acea65fb3011f1cd3fe2586 |
|
BLAKE2b-256 | cfec47029262ceda5ecd89865239b1ef3a44c14ebbc70d37dcbccb4249d716ba |
Close
Hashes for pybase16384-0.3.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40ffba44de535c6ec67a2f734991d9712797e471ae2e3f40d954af6546ca0305 |
|
MD5 | 0e69eb883fd421becaeecf5c653eeae7 |
|
BLAKE2b-256 | f1d71cb36b0ebfec49c13a988876638d36d535b857674f51d69a2ba0c99bb156 |
Close
Hashes for pybase16384-0.3.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c08129ca5bcf50dc4aeee00b57e97f9953ae6c2cb2dff10fd05100b4f69406 |
|
MD5 | 2042f919f906ce9e97952bb58cba3762 |
|
BLAKE2b-256 | 1b2efc78dd78fcea0874c9d5a64c6526a140aeb62ffb11256a36a4444448cf34 |