mscs 2.2.0__tar.gz → 2.2.1__tar.gz
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.
- mscs-2.2.1/.gitignore +207 -0
- {mscs-2.2.0 → mscs-2.2.1}/PKG-INFO +17 -34
- {mscs-2.2.0 → mscs-2.2.1}/README.md +13 -30
- {mscs-2.2.0 → mscs-2.2.1}/pyproject.toml +4 -4
- {mscs-2.2.0 → mscs-2.2.1}/LICENSE +0 -0
- {mscs-2.2.0 → mscs-2.2.1}/src/mscs/__init__.py +0 -0
- {mscs-2.2.0 → mscs-2.2.1}/src/mscs/_core.py +0 -0
- {mscs-2.2.0 → mscs-2.2.1}/src/mscs/py.typed +0 -0
mscs-2.2.1/.gitignore
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mscs
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Safe, fast serialization for Python — a secure replacement for pickle with native support for numpy arrays and PyTorch tensors.
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL: Repository, https://github.com/
|
|
7
|
-
Project-URL: Issues, https://github.com/
|
|
5
|
+
Project-URL: Homepage, https://github.com/ElEscribanoSilente/MSC-Serial
|
|
6
|
+
Project-URL: Repository, https://github.com/ElEscribanoSilente/MSC-Serial
|
|
7
|
+
Project-URL: Issues, https://github.com/ElEscribanoSilente/MSC-Serial/issues
|
|
8
8
|
Author: Esraderey
|
|
9
9
|
License-Expression: MIT
|
|
10
10
|
License-File: LICENSE
|
|
@@ -116,16 +116,14 @@ mscs.loads(data_with_unknown_class, strict=False) # {'__class__': '...', '__sta
|
|
|
116
116
|
### Backward Compatibility with Renamed Classes
|
|
117
117
|
|
|
118
118
|
```python
|
|
119
|
-
# Class was renamed from OldConfig to Config
|
|
120
119
|
mscs.register_alias("my_module.OldConfig", Config)
|
|
121
|
-
# Old checkpoints now deserialize correctly
|
|
122
120
|
```
|
|
123
121
|
|
|
124
122
|
### Register All Classes in a Module
|
|
125
123
|
|
|
126
124
|
```python
|
|
127
125
|
import my_models
|
|
128
|
-
mscs.register_module(my_models)
|
|
126
|
+
mscs.register_module(my_models)
|
|
129
127
|
```
|
|
130
128
|
|
|
131
129
|
## Compression & Integrity
|
|
@@ -174,17 +172,17 @@ mscs.loads(data) # verifies CRC, raises MSCDecodeError if corrupted
|
|
|
174
172
|
|
|
175
173
|
## Supported Types
|
|
176
174
|
|
|
177
|
-
| Type |
|
|
178
|
-
|
|
179
|
-
| `None`, `bool`, `int`, `float`, `complex` |
|
|
180
|
-
| `str`, `bytes`, `bytearray` |
|
|
181
|
-
| `list`, `tuple`, `dict`, `set`, `frozenset` |
|
|
182
|
-
| `datetime`, `date`, `time`, `timedelta` |
|
|
183
|
-
| `Decimal`, `UUID`, `Path` |
|
|
184
|
-
| `Enum` |
|
|
185
|
-
| `numpy.ndarray` |
|
|
186
|
-
| `torch.Tensor` |
|
|
187
|
-
| `dataclass`, `__slots__`, `__dict__`
|
|
175
|
+
| Type | Notes |
|
|
176
|
+
|------|-------|
|
|
177
|
+
| `None`, `bool`, `int`, `float`, `complex` | Arbitrary precision ints |
|
|
178
|
+
| `str`, `bytes`, `bytearray` | UTF-8, ref-tracked |
|
|
179
|
+
| `list`, `tuple`, `dict`, `set`, `frozenset` | Circular refs supported |
|
|
180
|
+
| `datetime`, `date`, `time`, `timedelta` | ISO 8601 |
|
|
181
|
+
| `Decimal`, `UUID`, `Path` | Lossless |
|
|
182
|
+
| `Enum` | Must be registered |
|
|
183
|
+
| `numpy.ndarray` | dtype whitelist enforced |
|
|
184
|
+
| `torch.Tensor` | Auto CPU transfer, preserves requires_grad |
|
|
185
|
+
| `dataclass`, `__slots__`, `__dict__` objects | Must be registered |
|
|
188
186
|
|
|
189
187
|
## Performance
|
|
190
188
|
|
|
@@ -196,15 +194,7 @@ Benchmarked on a state_dict with 4 tensors (~57K parameters):
|
|
|
196
194
|
| pickle | 0.580 ms | 68 KB | No (RCE) |
|
|
197
195
|
| torch.save | 0.437 ms | 67 KB | No (RCE) |
|
|
198
196
|
|
|
199
|
-
**5.9x faster than pickle, 4.1x faster than torch.save
|
|
200
|
-
|
|
201
|
-
Tensor scaling (encode+decode):
|
|
202
|
-
|
|
203
|
-
| Shape | mscs | pickle | Speedup |
|
|
204
|
-
|-------|------|--------|---------|
|
|
205
|
-
| 10x10 | 0.019 ms | 0.156 ms | 8.2x |
|
|
206
|
-
| 256x256 | 0.069 ms | 0.278 ms | 4.0x |
|
|
207
|
-
| 1024x1024 | 4.7 ms | 5.0 ms | 1.1x |
|
|
197
|
+
**5.9x faster than pickle, 4.1x faster than torch.save.**
|
|
208
198
|
|
|
209
199
|
## Security Model
|
|
210
200
|
|
|
@@ -215,7 +205,6 @@ Tensor scaling (encode+decode):
|
|
|
215
205
|
5. **Configurable limits**: `MAX_DEPTH=256`, `MAX_SIZE=512MB`, `MAX_COLLECTION=10M`
|
|
216
206
|
6. **Anti zip-bomb**: `load_compressed` validates both compressed and decompressed sizes
|
|
217
207
|
7. **CRC32 integrity**: Optional checksum to detect corruption
|
|
218
|
-
8. **Auditable format**: Magic bytes (`MSCS`) + version byte + type tags
|
|
219
208
|
|
|
220
209
|
## Binary Format
|
|
221
210
|
|
|
@@ -223,12 +212,6 @@ Tensor scaling (encode+decode):
|
|
|
223
212
|
[MSCS][version:1][flags:1][type_tag:1][...payload...]
|
|
224
213
|
```
|
|
225
214
|
|
|
226
|
-
- Magic: `MSCS` (4 bytes)
|
|
227
|
-
- Version: `\x02` (1 byte)
|
|
228
|
-
- Flags: bit 0 = CRC32 appended (1 byte)
|
|
229
|
-
- Payload: recursive type-tagged binary data
|
|
230
|
-
- Optional CRC32 trailer (4 bytes)
|
|
231
|
-
|
|
232
215
|
## License
|
|
233
216
|
|
|
234
217
|
MIT
|
|
@@ -79,16 +79,14 @@ mscs.loads(data_with_unknown_class, strict=False) # {'__class__': '...', '__sta
|
|
|
79
79
|
### Backward Compatibility with Renamed Classes
|
|
80
80
|
|
|
81
81
|
```python
|
|
82
|
-
# Class was renamed from OldConfig to Config
|
|
83
82
|
mscs.register_alias("my_module.OldConfig", Config)
|
|
84
|
-
# Old checkpoints now deserialize correctly
|
|
85
83
|
```
|
|
86
84
|
|
|
87
85
|
### Register All Classes in a Module
|
|
88
86
|
|
|
89
87
|
```python
|
|
90
88
|
import my_models
|
|
91
|
-
mscs.register_module(my_models)
|
|
89
|
+
mscs.register_module(my_models)
|
|
92
90
|
```
|
|
93
91
|
|
|
94
92
|
## Compression & Integrity
|
|
@@ -137,17 +135,17 @@ mscs.loads(data) # verifies CRC, raises MSCDecodeError if corrupted
|
|
|
137
135
|
|
|
138
136
|
## Supported Types
|
|
139
137
|
|
|
140
|
-
| Type |
|
|
141
|
-
|
|
142
|
-
| `None`, `bool`, `int`, `float`, `complex` |
|
|
143
|
-
| `str`, `bytes`, `bytearray` |
|
|
144
|
-
| `list`, `tuple`, `dict`, `set`, `frozenset` |
|
|
145
|
-
| `datetime`, `date`, `time`, `timedelta` |
|
|
146
|
-
| `Decimal`, `UUID`, `Path` |
|
|
147
|
-
| `Enum` |
|
|
148
|
-
| `numpy.ndarray` |
|
|
149
|
-
| `torch.Tensor` |
|
|
150
|
-
| `dataclass`, `__slots__`, `__dict__`
|
|
138
|
+
| Type | Notes |
|
|
139
|
+
|------|-------|
|
|
140
|
+
| `None`, `bool`, `int`, `float`, `complex` | Arbitrary precision ints |
|
|
141
|
+
| `str`, `bytes`, `bytearray` | UTF-8, ref-tracked |
|
|
142
|
+
| `list`, `tuple`, `dict`, `set`, `frozenset` | Circular refs supported |
|
|
143
|
+
| `datetime`, `date`, `time`, `timedelta` | ISO 8601 |
|
|
144
|
+
| `Decimal`, `UUID`, `Path` | Lossless |
|
|
145
|
+
| `Enum` | Must be registered |
|
|
146
|
+
| `numpy.ndarray` | dtype whitelist enforced |
|
|
147
|
+
| `torch.Tensor` | Auto CPU transfer, preserves requires_grad |
|
|
148
|
+
| `dataclass`, `__slots__`, `__dict__` objects | Must be registered |
|
|
151
149
|
|
|
152
150
|
## Performance
|
|
153
151
|
|
|
@@ -159,15 +157,7 @@ Benchmarked on a state_dict with 4 tensors (~57K parameters):
|
|
|
159
157
|
| pickle | 0.580 ms | 68 KB | No (RCE) |
|
|
160
158
|
| torch.save | 0.437 ms | 67 KB | No (RCE) |
|
|
161
159
|
|
|
162
|
-
**5.9x faster than pickle, 4.1x faster than torch.save
|
|
163
|
-
|
|
164
|
-
Tensor scaling (encode+decode):
|
|
165
|
-
|
|
166
|
-
| Shape | mscs | pickle | Speedup |
|
|
167
|
-
|-------|------|--------|---------|
|
|
168
|
-
| 10x10 | 0.019 ms | 0.156 ms | 8.2x |
|
|
169
|
-
| 256x256 | 0.069 ms | 0.278 ms | 4.0x |
|
|
170
|
-
| 1024x1024 | 4.7 ms | 5.0 ms | 1.1x |
|
|
160
|
+
**5.9x faster than pickle, 4.1x faster than torch.save.**
|
|
171
161
|
|
|
172
162
|
## Security Model
|
|
173
163
|
|
|
@@ -178,7 +168,6 @@ Tensor scaling (encode+decode):
|
|
|
178
168
|
5. **Configurable limits**: `MAX_DEPTH=256`, `MAX_SIZE=512MB`, `MAX_COLLECTION=10M`
|
|
179
169
|
6. **Anti zip-bomb**: `load_compressed` validates both compressed and decompressed sizes
|
|
180
170
|
7. **CRC32 integrity**: Optional checksum to detect corruption
|
|
181
|
-
8. **Auditable format**: Magic bytes (`MSCS`) + version byte + type tags
|
|
182
171
|
|
|
183
172
|
## Binary Format
|
|
184
173
|
|
|
@@ -186,12 +175,6 @@ Tensor scaling (encode+decode):
|
|
|
186
175
|
[MSCS][version:1][flags:1][type_tag:1][...payload...]
|
|
187
176
|
```
|
|
188
177
|
|
|
189
|
-
- Magic: `MSCS` (4 bytes)
|
|
190
|
-
- Version: `\x02` (1 byte)
|
|
191
|
-
- Flags: bit 0 = CRC32 appended (1 byte)
|
|
192
|
-
- Payload: recursive type-tagged binary data
|
|
193
|
-
- Optional CRC32 trailer (4 bytes)
|
|
194
|
-
|
|
195
178
|
## License
|
|
196
179
|
|
|
197
180
|
MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mscs"
|
|
7
|
-
version = "2.2.
|
|
7
|
+
version = "2.2.1"
|
|
8
8
|
description = "Safe, fast serialization for Python — a secure replacement for pickle with native support for numpy arrays and PyTorch tensors."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -41,9 +41,9 @@ torch = ["numpy>=1.20", "torch>=2.0"]
|
|
|
41
41
|
all = ["numpy>=1.20", "torch>=2.0"]
|
|
42
42
|
|
|
43
43
|
[project.urls]
|
|
44
|
-
Homepage = "https://github.com/
|
|
45
|
-
Repository = "https://github.com/
|
|
46
|
-
Issues = "https://github.com/
|
|
44
|
+
Homepage = "https://github.com/ElEscribanoSilente/MSC-Serial"
|
|
45
|
+
Repository = "https://github.com/ElEscribanoSilente/MSC-Serial"
|
|
46
|
+
Issues = "https://github.com/ElEscribanoSilente/MSC-Serial/issues"
|
|
47
47
|
|
|
48
48
|
[tool.hatch.build.targets.sdist]
|
|
49
49
|
include = ["src/mscs/"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|