fast 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: ...
def encode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
def decode_local_file(inp: Union[str, bytes, Path], out: Union[str, bytes, Path], encsize: int, decsize: int) -> None: ...
def encode_fd(inp: int, out: int) -> None: ...
def decode_fd(inp: int, out: int) -> None: ...
-
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
- 为了在windows上编译,需要加点料,把 这个 放进msvc的目录
后端选择
默认由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.4.tar.gz
(211.3 kB
view hashes)
Built Distributions
Close
Hashes for pybase16384-0.3.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c20f69612eae0487f63a326c421b4bed0c6422bf04c51fe03b852f4f433ecc8c |
|
MD5 | 786d68f22ba03032b2cf344cf7aea77b |
|
BLAKE2b-256 | 70b9a3857a6306bf01c81f6c6cf4d84db5b90b692fdf55c8de0db6cf8513f402 |
Close
Hashes for pybase16384-0.3.4-pp310-pypy310_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6292322971ea64792298c26dca94d3c2491cd9f61f95a6919187eaa6eb5790f3 |
|
MD5 | 0c725bb1874deb1843f29f1947ef3201 |
|
BLAKE2b-256 | 8c4cad398a06085e1296e652e250c2f4dcd1bf69d66cb15c20c6614e48ad8a2d |
Close
Hashes for pybase16384-0.3.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bf14cc1b6cdcd5a21b282fbb13c38e95ef9768ed092171d738f853844491f0b |
|
MD5 | 46ee508d83960c6f633e6bea98492266 |
|
BLAKE2b-256 | 9fe01b3953c972bc816ef3232de9d81a7abb2f0ec03e1b04fec6d1762961309b |
Close
Hashes for pybase16384-0.3.4-pp310-pypy310_pp73-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7e94d9cc4206ebfa023f051a8e040719391b71641c09477dc5ef26b8644ec4a |
|
MD5 | bca55b24f03b8de3b96a6e7371a7d529 |
|
BLAKE2b-256 | 5f916da30e12aa6e63910adbd313c9874ce48006b73180cf4681b6cdbaf2c324 |
Close
Hashes for pybase16384-0.3.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56c04f0cc7b1c5039792106d8c5f588393074963362f54b97a03c8d74285b2b1 |
|
MD5 | f51bf1788eb08b8a94c632fe231e2ad5 |
|
BLAKE2b-256 | b98b433e778cef9429102d525d399d556535014df99f5cc3f8414c0be1960cb3 |
Close
Hashes for pybase16384-0.3.4-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa197c532fc085520b6d113bd6533e20b559fe29214567d6b808c740a825d6e4 |
|
MD5 | 8543e479d13e01a51a5e3ba3ed987a25 |
|
BLAKE2b-256 | 365f39dba59f91b1e86b5b24df7b2db3fedae0395b9099204d6c7d2debf532ec |
Close
Hashes for pybase16384-0.3.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 559e29e3bf7542319d4d4e738db5d0911959fea332ad4baa191da4835e5ac373 |
|
MD5 | 725fde52313b13435f22b7f42185ee6b |
|
BLAKE2b-256 | 2e3d14f8eddac0947adcb37e96e15176ae0c412ab4e75785289f9dfcae2523e2 |
Close
Hashes for pybase16384-0.3.4-pp39-pypy39_pp73-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e748a8e3c58835d7a23f7a4514e764f57e0b8596258cc019543c80061d98df |
|
MD5 | 471796dfaa771e5073d656de9784da9b |
|
BLAKE2b-256 | d723c8e506e7f4e0e677062b7ab25b8f15f797a12da439edc29403f7bf4e9111 |
Close
Hashes for pybase16384-0.3.4-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a774d83db1aee0b8d2d80848291d89792dc0fc1d9067e94e231d8be2e05bc0b |
|
MD5 | 23e7d159a4318dbf9f61e0a435d67d55 |
|
BLAKE2b-256 | 591759cfe6401a92b3100a010bd5c31da4d97379d32a8d5f0c93e17343a26d23 |
Close
Hashes for pybase16384-0.3.4-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e271cb5b190b8d2852911415feb2a27fa2d4e4c211ba2711a699890a83671e0 |
|
MD5 | 77b42fcc70c8f9a7a8762489a2badae3 |
|
BLAKE2b-256 | 733d6a6e3cc4a392d06b4c8b111186b585ed1adea34407295a6e53c842621464 |
Close
Hashes for pybase16384-0.3.4-pp38-pypy38_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e3fa733043adb2e0d291139a99a9b9ee9d36d8022f3731767877bdcedad1185 |
|
MD5 | 11438273d42a469f934c949896c86205 |
|
BLAKE2b-256 | ddc68e29896e4afd2559517b63e2769a8d6993506057ede7fa612996b8b60bf8 |
Close
Hashes for pybase16384-0.3.4-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abc264134bf4b3ba333f0e71f8a65c377cf0f9c72958d218e281f6c220ed803a |
|
MD5 | 94d3b20b6417679cae9912325e18e332 |
|
BLAKE2b-256 | 3b87167c9bae9272db20c151ba0fc1810c2a7157cf8a3d337b23dbb345b443d5 |
Close
Hashes for pybase16384-0.3.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a56901d628b0d60f640f33a1e0aa1c5fc6dc8b96bbc42a8751cca6f01bcaef6e |
|
MD5 | 4a657febf9216977aec61e52e9bcec41 |
|
BLAKE2b-256 | 4d888c4567396a3fcea69b12a675696c472b23d9a5af85f76e7443621fbdaf03 |
Close
Hashes for pybase16384-0.3.4-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67c2d6f5c11a76114250f8c770a1186cf4c1229c4b8dd0449d19c96a260d7200 |
|
MD5 | 38bc4eea810e92211f8e2f690d72bf40 |
|
BLAKE2b-256 | 3cc36bbb1f249c139e819baae462a6c511bcd5d0451eb0fa2a9c6aa4683e8912 |
Close
Hashes for pybase16384-0.3.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5b3502375800b468b026f8980133ee618515c986f62cbea21332a117f1c71c7 |
|
MD5 | 8a05e2235311955ddfeba2ea9b05bf1c |
|
BLAKE2b-256 | ef17a8ddfd15f4cd28e9415710fe8f45ffe58390507406a6bd9eb684eac3019e |
Close
Hashes for pybase16384-0.3.4-cp312-cp312-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d16079c53f51d06f466515eb0410af6beb35391d50eb0a2e42090248a034b2ae |
|
MD5 | b92d58226f7a7262b4eed4861563b4d9 |
|
BLAKE2b-256 | 78822d879d14db8b50ce3797f3419094e5d687f8efc4cc48b88fedede0b54065 |
Close
Hashes for pybase16384-0.3.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392213ff6f9ce94d600e0f107f47a945f82a08fa0270c5e16c5c19065197fdb0 |
|
MD5 | 13b031366ee1ad2fb90ca5b97ebcab80 |
|
BLAKE2b-256 | 2398cc18a0cbbc9bd34d7f6e994a29d4c8ec9c67d8ded6cd0b030c9790b403c4 |
Close
Hashes for pybase16384-0.3.4-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a65b19384c036700ee6de8a36502577dda0ef3265063ebdbe93582df679f852 |
|
MD5 | 394aea90ae25be53c9903fd62468eaaf |
|
BLAKE2b-256 | 1fa5023e2f2c20876dd3323ed469791db446ea3c31ee0e0687fd4045b5ad68e8 |
Close
Hashes for pybase16384-0.3.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 777c90746bdea3bfc005a7fcdbedfabc64a4d0db1d3614892f8b8c8e9d9c27aa |
|
MD5 | 1b933e453ba73d5f0ee7d19308023cdb |
|
BLAKE2b-256 | 29054a02d6891cab1d03ab493dbba865c6e302f494f97bc969f930c622d5f155 |
Close
Hashes for pybase16384-0.3.4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c67fa3f7fdb5eb8bfbe53231d3bf383dd5d0b0b4bda2bbfea7573e364a64be92 |
|
MD5 | b99419c8894ca7fe74a679806199ddfa |
|
BLAKE2b-256 | 3b736ac20cce85950ad06448711dbd3ebfe9814bc4845edbd321ab5bb33a40d9 |
Close
Hashes for pybase16384-0.3.4-cp311-cp311-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b76dc251b39ae98ff72ca2100d87df6e2480e001654f693699aa44db0466fc3e |
|
MD5 | d478d27f81a89d12923536daaa7ef007 |
|
BLAKE2b-256 | 296a19fd53dd8570140ad42dcfe703d268ca9e2d02ba267618742047b9daaa1e |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cab437dae6619b2b566ff6ecbe890718fe50350a12fb5f087bb4bad1f4ee22d |
|
MD5 | b8dfddaf51374bfa271ad4d79d18a37d |
|
BLAKE2b-256 | f179c8defdd13f86c741aeafc0ecb2e64ab58c8816f3f44548b61b246c0d48fa |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cb4703c8aef4d85ebd309aeed38d40805842edfa3f1efaa34e0a36bb221c23 |
|
MD5 | 3ec75443afa2b969ff702f5244733f8f |
|
BLAKE2b-256 | e1cc3c5c57764789c50557b54157d90444f0b7c4c2f6110317bd7cd2db220ad7 |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd7a135a0b97a33921f3ce6dec8e797c249acb18eab77c7e9cfab4f3378cc594 |
|
MD5 | 5647e48f06b6e0f51089a3beeac06048 |
|
BLAKE2b-256 | 0b5b2ce5f93bbc75b8bc303ec31bfee39927e679858c286d451903e4f61f6df9 |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9184a8f87ddcaf00a2e74d886d1ea3f7194e68f3aadda1ad413898826113ed0 |
|
MD5 | 152a625f17ffa3c0267bc842f5618442 |
|
BLAKE2b-256 | 134c215ee9d1eb19516fb0a27572d823eeef619626b9dbb0261c80238ee7406b |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de16628883beb9c6f4f912d6a506feb1df6f1f207c4e3fcebf1fa5bfec9c914 |
|
MD5 | 4a3e4398171ec452c24530d80c52a8c0 |
|
BLAKE2b-256 | bea434c6f23dd8598c94a251aaea2f8da8d26856ab5ab5412cb3234739eab7a7 |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d68848f72da9ee41005536f8e731144122f0a2b0da5164b7702f05fc064f8a36 |
|
MD5 | 597ca7c16c3fbb42a96ecf3d28bc7d16 |
|
BLAKE2b-256 | 726daa0beb21555926c78224b996a1328c302e58d91d8fc09d0cff1b6dfed813 |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e2d41bdebb0256a3a1b96a930a81b8f169db7e00f0da9230af03ccec787af3 |
|
MD5 | d93df5e5a2d15324866a17724fcc5fbd |
|
BLAKE2b-256 | fc0edc56b04a1cbc8e9a758800e60b52db0df66817da85c544b8285badd94fb0 |
Close
Hashes for pybase16384-0.3.4-cp310-cp310-macosx_10_9_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 151defccf2a7cb609709c3e640a75ff35c9219e46b08cad31deb47d5f2edb1f5 |
|
MD5 | e100b830e2c94362312087feded51f42 |
|
BLAKE2b-256 | 19876834ed1d5802bec7233a19753d591b539e15c0a75df72d4875d71f71efba |
Close
Hashes for pybase16384-0.3.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e6539d3a290d81b7e8600162fd501bc7776aa0641353eeb8e2f6594dbe11ce6 |
|
MD5 | 3a94b438a1d79d863a8df4cfc11f857a |
|
BLAKE2b-256 | 9677e4462139e78792371356f5ca4b239b04068cb30e1cf408ab6c66e176c18f |
Close
Hashes for pybase16384-0.3.4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8a2148a2291e6533915600d7e0794226ad888293de584c3a679abab3d89d34c |
|
MD5 | afe88a068a249e72370b358629ef0963 |
|
BLAKE2b-256 | dd25c878946aff53582fb734f9dd849a12f169c02926b85f245adb8855c36a24 |
Close
Hashes for pybase16384-0.3.4-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79526e6a7af9eed5646a8ef428d7eab08a59aa73a9d58244602e98657a920e28 |
|
MD5 | 6caf8904161a37b60255ec8643438881 |
|
BLAKE2b-256 | 931d2efc3b14262114de4d0872a5cf5f942f44719057a820e2d68ebb4eae6971 |
Close
Hashes for pybase16384-0.3.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4301bebf0ef49b0193dacd4f01d22115126aa246a7ffe904c35087857b92d03 |
|
MD5 | c6c7d3da4a7819fb4c4b7d66aa7d416e |
|
BLAKE2b-256 | 429648cae4ddfbd86995451042b8ffee16c7325edf24f50019153ef008ecc651 |
Close
Hashes for pybase16384-0.3.4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a68d2c8db97e123e926e836977475ce261e0b303e57a61f3a14e120d4b209e |
|
MD5 | 36ef95070f1b5cea1c5137188b7f212e |
|
BLAKE2b-256 | 7ee27e9ca7141b4b94e46b7a0f48f53de83da4fa7aa27b06024f1f0b29a456ee |
Close
Hashes for pybase16384-0.3.4-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f9d0b7016f86d6d7af624bce3b0c17d66d71749a717ca45dc53dc2211a9fdd7 |
|
MD5 | ee126d19bfd2433fbd6e0c4b20461664 |
|
BLAKE2b-256 | 51bcd3a0e46106ae6dca2838dee7a22f59fc13526e4ddaff24d535bce50f3ae5 |