sub-byte 0.0.7__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ * text eol=lf
@@ -0,0 +1,64 @@
1
+ name: Run PyTest
2
+
3
+ description: Run the API Fuzz tests using Pytest and Hypothesis
4
+
5
+ on:
6
+ push:
7
+ pull_request:
8
+ workflow_call:
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+
13
+ run_tests:
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: [
18
+ "3.12",
19
+ "3.13",
20
+ "3.14.0-alpha.3",
21
+ ]
22
+ os: [
23
+ "ubuntu-24.04",
24
+ ]
25
+ include:
26
+
27
+ - os: "macos-latest"
28
+ python-version: "3.13"
29
+ - os: "windows-latest"
30
+ python-version: "3.13"
31
+
32
+ runs-on: ${{ matrix.os }}
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+
36
+ - uses: actions/setup-python@v5
37
+ with:
38
+ python-version: ${{ matrix.python-version }}
39
+
40
+ - name: Install test dependencies
41
+ run: pip install pytest hypothesis
42
+
43
+ - name: Install code under test
44
+ run: pip install -e .
45
+
46
+
47
+ - uses: denoland/setup-deno@v2
48
+ with:
49
+ deno-version: v2.x
50
+
51
+ - name: Show files in tests dir
52
+ working-directory: tests
53
+ shell: bash
54
+ run: ls -A
55
+
56
+ - name: Install JS deps from npm
57
+ run: npm ci
58
+
59
+ - name: Run JS tests
60
+ run: npm run test
61
+
62
+ - name: Run Python tests (JS tested via CLI).
63
+ working-directory: tests
64
+ run: pytest
@@ -0,0 +1,63 @@
1
+ name: Type check Python
2
+
3
+ description: Run Mypy and Pyright etc.
4
+
5
+ on:
6
+ push:
7
+ pull_request:
8
+ workflow_call:
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+
13
+ mypy:
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: [
18
+ 3.13,
19
+ ]
20
+ os: [
21
+ "ubuntu-latest",
22
+ ]
23
+
24
+ runs-on: ${{ matrix.os }}
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+
28
+ - uses: actions/setup-python@v5
29
+ with:
30
+ python-version: ${{ matrix.python-version }}
31
+
32
+ - name: Install code for deps
33
+ run: pip install -e .[mypy]
34
+
35
+ - name: Run mypy
36
+ run: mypy src/sub_byte
37
+
38
+ pyright:
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ python-version: [
43
+ 3.13,
44
+ ]
45
+ os: [
46
+ "ubuntu-latest",
47
+ ]
48
+
49
+ runs-on: ${{ matrix.os }}
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: ${{ matrix.python-version }}
56
+
57
+ - name: Install code for deps
58
+ run: pip install -e .
59
+
60
+ - uses: jakebailey/pyright-action@v2
61
+ with:
62
+ extra-args:
63
+ src/sub_byte/factories.py
@@ -0,0 +1,167 @@
1
+ .vscode/*
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
107
+ __pypackages__/
108
+
109
+ # Celery stuff
110
+ celerybeat-schedule
111
+ celerybeat.pid
112
+
113
+ # SageMath parsed files
114
+ *.sage.py
115
+
116
+ # Environments
117
+ .env
118
+ .venv
119
+ env/
120
+ venv/
121
+ ENV/
122
+ env.bak/
123
+ venv.bak/
124
+
125
+ # Spyder project settings
126
+ .spyderproject
127
+ .spyproject
128
+
129
+ # Rope project settings
130
+ .ropeproject
131
+
132
+ # mkdocs documentation
133
+ /site
134
+
135
+ # mypy
136
+ .mypy_cache/
137
+ .dmypy.json
138
+ dmypy.json
139
+
140
+ # Pyre type checker
141
+ .pyre/
142
+
143
+ # pytype static type analyzer
144
+ .pytype/
145
+
146
+ # Cython debug symbols
147
+ cython_debug/
148
+
149
+ # PyCharm
150
+ # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
151
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
152
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
153
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
154
+ #.idea/
155
+
156
+ number_cache.py
157
+ *.dat
158
+ grades_goals_forms_solutions
159
+ *.tar.gz
160
+
161
+ sols*
162
+ *.zip
163
+ tests/pg100.txt
164
+ /node_modules
165
+
166
+ *.tgz
167
+ .eslintcache
File without changes
@@ -0,0 +1,4 @@
1
+ # Ignore artifacts:
2
+ build
3
+ coverage
4
+ .github
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present James Parrott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: sub-byte
3
+ Version: 0.0.7
4
+ Summary: Encodes and decodes sequences of unsigned integers with known widths (and sequences of symbols from finite sets).
5
+ Project-URL: Homepage, https://github.com/NumberzGame/sub_byte
6
+ Project-URL: Bug Tracker, https://github.com/NumberzGame/sub_byte/issues
7
+ Author-email: James Parrott <james.parrott@proton.me>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2024-present James Parrott
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ License-File: LICENSE.md
18
+ Keywords: Encoders,Serialization
19
+ Classifier: Programming Language :: Python
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: more-itertools
22
+ Provides-Extra: mypy
23
+ Requires-Dist: mypy; extra == 'mypy'
24
+ Provides-Extra: test
25
+ Requires-Dist: hypothesis; extra == 'test'
26
+ Requires-Dist: pytest; extra == 'test'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Sub_Byte
30
+
31
+ Bit packer and depacker. Encodes and decodes sequences of integers with known bit-widths (and sequences of symbols equivalent to integers under some mapping).
32
+
33
+ ## Overview
34
+
35
+ Sub Byte stores data without wasting bits, while preserving its structure, without requiring compression or decompression. Simple bit packing is used, supporting using less than a byte of storage for <=7 bit fields, crossing byte
36
+ boundaries if necessary.
37
+
38
+ A bit width for each symbol is required. The bit width sequence (a simple codec) can be associated with the encoded data as meta data. The decoder can be passed the total number of symbols to decode (e.g. whether a null byte (0b00000000), is 8 1-bit zeros, 4 2-bit zeros, 2 u4 zeros or a single u8 zero).
39
+
40
+ Alternatively, more dynamic codecs can be supported by passing null for the number of symbols to the decoder. Axtra custom code
41
+ must then be written by the user, to determine when iteration ceases. This can be used e.g. to encode the actual bit widths first (in some other fixed bit widths), to encode the number of symbols or cycles, and to implement any other codec that determines bit widths, and termination of iteration, according to the user's code.
42
+
43
+ Data validation (e.g. checksums or hashes) must be done by the user, but an extra field can easily be appended to a bit width cycle.
44
+
45
+ ## Implementations
46
+
47
+ ### Python
48
+ Calculate a cache of data in Python.
49
+
50
+ ```shell
51
+ uv pip install sub_byte
52
+ ```
53
+
54
+
55
+ ### Typescript/Javascript
56
+ Decode a cache of data in Javascript, even in browser.
57
+
58
+ ```shell
59
+ npm i sub_byte
60
+ ```
61
+
62
+
63
+ ## Alternatives
64
+
65
+ ### Sub 4kB datasets
66
+ This library is not needed for data storage. Neither Sub_byte nor anything else, will reduce the disk space used.
67
+ If the size of the un-encoded data set is less 4kB for example (or the page size of the file system on which the data will be stored, e.g. ext4, NTFS, APFS) then it is already below the minimum file size for that file system.
68
+
69
+ ### A bespoke protocol using custom width integer types
70
+
71
+ Up to 8 u1s (bits), up to 4 u2s, or up to 2 u3s or u4s per byte.
72
+ Each developer must create their own implementation and tests.
73
+ Interoperability between different private implementations is untestable.
74
+
75
+ ### Protocol buffers
76
+
77
+ Encodes max symbol per byte. Variable byte encoding - uses continuation bits.
78
+
79
+ ### Zipping (data compression)
80
+
81
+ - Exploits statistical distributions (e.g. "E" being more common in English text than "Q") and patterns.
82
+ - Unstructured until the end user unzips the archive.
83
+
84
+ ## Changelog
85
+ ### v0.05
86
+ Configured npm module for Typescript.
87
+ ### v0.04
88
+ Support dynamic codecs (null/None number of elements to decode).
89
+
90
+ ## Development
91
+
92
+ ### Type checking and linting:
93
+ #### Python
94
+ ##### MyPy
95
+ ```shell
96
+ mypy --python-executable=path/to/venv/where/deps/installed/python.exe src/sub_byte
97
+ ```
98
+
99
+ ##### Pyright
100
+ Activate venv where deps installed
101
+ ```shell
102
+ pyright src/sub_byte/factories.py
103
+ ```
104
+
105
+ #### TS
106
+ ##### Typescipt compiler
107
+ ```shell
108
+ npm run typecheck
109
+ ```
110
+ ##### Eslint
111
+ ```shell
112
+ npm run eslint
113
+ ```
114
+
115
+ ##### Prettier
116
+ ###### Check
117
+ ```shell
118
+ npm run prettier
119
+ ```
120
+
121
+ ###### Auto fix
122
+ ```shell
123
+ npm run prettier:write
124
+ ```
125
+
126
+ ### Publishing
127
+
128
+ Bump version in package.json to x.y.z
129
+
130
+ #### NPM
131
+ ```shell
132
+ npm run prepublish
133
+ npm pack
134
+ ```
135
+ Double check contents of sub_byte-x.y.z.tgz
136
+
137
+ ```shell
138
+ npm publish
139
+ ```
140
+ Sign in (currently requires being the author).
141
+
142
+ #### PyPi
143
+
144
+
@@ -0,0 +1,116 @@
1
+ # Sub_Byte
2
+
3
+ Bit packer and depacker. Encodes and decodes sequences of integers with known bit-widths (and sequences of symbols equivalent to integers under some mapping).
4
+
5
+ ## Overview
6
+
7
+ Sub Byte stores data without wasting bits, while preserving its structure, without requiring compression or decompression. Simple bit packing is used, supporting using less than a byte of storage for <=7 bit fields, crossing byte
8
+ boundaries if necessary.
9
+
10
+ A bit width for each symbol is required. The bit width sequence (a simple codec) can be associated with the encoded data as meta data. The decoder can be passed the total number of symbols to decode (e.g. whether a null byte (0b00000000), is 8 1-bit zeros, 4 2-bit zeros, 2 u4 zeros or a single u8 zero).
11
+
12
+ Alternatively, more dynamic codecs can be supported by passing null for the number of symbols to the decoder. Axtra custom code
13
+ must then be written by the user, to determine when iteration ceases. This can be used e.g. to encode the actual bit widths first (in some other fixed bit widths), to encode the number of symbols or cycles, and to implement any other codec that determines bit widths, and termination of iteration, according to the user's code.
14
+
15
+ Data validation (e.g. checksums or hashes) must be done by the user, but an extra field can easily be appended to a bit width cycle.
16
+
17
+ ## Implementations
18
+
19
+ ### Python
20
+ Calculate a cache of data in Python.
21
+
22
+ ```shell
23
+ uv pip install sub_byte
24
+ ```
25
+
26
+
27
+ ### Typescript/Javascript
28
+ Decode a cache of data in Javascript, even in browser.
29
+
30
+ ```shell
31
+ npm i sub_byte
32
+ ```
33
+
34
+
35
+ ## Alternatives
36
+
37
+ ### Sub 4kB datasets
38
+ This library is not needed for data storage. Neither Sub_byte nor anything else, will reduce the disk space used.
39
+ If the size of the un-encoded data set is less 4kB for example (or the page size of the file system on which the data will be stored, e.g. ext4, NTFS, APFS) then it is already below the minimum file size for that file system.
40
+
41
+ ### A bespoke protocol using custom width integer types
42
+
43
+ Up to 8 u1s (bits), up to 4 u2s, or up to 2 u3s or u4s per byte.
44
+ Each developer must create their own implementation and tests.
45
+ Interoperability between different private implementations is untestable.
46
+
47
+ ### Protocol buffers
48
+
49
+ Encodes max symbol per byte. Variable byte encoding - uses continuation bits.
50
+
51
+ ### Zipping (data compression)
52
+
53
+ - Exploits statistical distributions (e.g. "E" being more common in English text than "Q") and patterns.
54
+ - Unstructured until the end user unzips the archive.
55
+
56
+ ## Changelog
57
+ ### v0.05
58
+ Configured npm module for Typescript.
59
+ ### v0.04
60
+ Support dynamic codecs (null/None number of elements to decode).
61
+
62
+ ## Development
63
+
64
+ ### Type checking and linting:
65
+ #### Python
66
+ ##### MyPy
67
+ ```shell
68
+ mypy --python-executable=path/to/venv/where/deps/installed/python.exe src/sub_byte
69
+ ```
70
+
71
+ ##### Pyright
72
+ Activate venv where deps installed
73
+ ```shell
74
+ pyright src/sub_byte/factories.py
75
+ ```
76
+
77
+ #### TS
78
+ ##### Typescipt compiler
79
+ ```shell
80
+ npm run typecheck
81
+ ```
82
+ ##### Eslint
83
+ ```shell
84
+ npm run eslint
85
+ ```
86
+
87
+ ##### Prettier
88
+ ###### Check
89
+ ```shell
90
+ npm run prettier
91
+ ```
92
+
93
+ ###### Auto fix
94
+ ```shell
95
+ npm run prettier:write
96
+ ```
97
+
98
+ ### Publishing
99
+
100
+ Bump version in package.json to x.y.z
101
+
102
+ #### NPM
103
+ ```shell
104
+ npm run prepublish
105
+ npm pack
106
+ ```
107
+ Double check contents of sub_byte-x.y.z.tgz
108
+
109
+ ```shell
110
+ npm publish
111
+ ```
112
+ Sign in (currently requires being the author).
113
+
114
+ #### PyPi
115
+
116
+
@@ -0,0 +1,39 @@
1
+ {
2
+ "version": "4",
3
+ "specifiers": {
4
+ "jsr:@std/assert@*": "1.0.10",
5
+ "jsr:@std/assert@^1.0.10": "1.0.10",
6
+ "jsr:@std/internal@^1.0.5": "1.0.5",
7
+ "jsr:@std/testing@*": "1.0.8"
8
+ },
9
+ "jsr": {
10
+ "@std/assert@1.0.10": {
11
+ "integrity": "59b5cbac5bd55459a19045d95cc7c2ff787b4f8527c0dd195078ff6f9481fbb3",
12
+ "dependencies": [
13
+ "jsr:@std/internal"
14
+ ]
15
+ },
16
+ "@std/internal@1.0.5": {
17
+ "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
18
+ },
19
+ "@std/testing@1.0.8": {
20
+ "integrity": "ceef535808fb7568e91b0f8263599bd29b1c5603ffb0377227f00a8ca9fe42a2",
21
+ "dependencies": [
22
+ "jsr:@std/assert@^1.0.10",
23
+ "jsr:@std/internal"
24
+ ]
25
+ }
26
+ },
27
+ "workspace": {
28
+ "packageJson": {
29
+ "dependencies": [
30
+ "npm:@eslint/js@^9.13.0",
31
+ "npm:eslint@^9.13.0",
32
+ "npm:fast-check@^3.22.0",
33
+ "npm:globals@^15.11.0",
34
+ "npm:mocha@^10.7.3",
35
+ "npm:prettier@3.3.3"
36
+ ]
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,12 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+
4
+ export default [
5
+ { languageOptions: { globals: globals.browser, ecmaVersion: "latest" } },
6
+ pluginJs.configs.recommended,
7
+ {
8
+ rules: {
9
+ camelcase: "error",
10
+ },
11
+ },
12
+ ];