obstruct 0.2.2__tar.gz → 0.2.3__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.
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/workspace.xml +2 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/PKG-INFO +19 -3
- {obstruct-0.2.2 → obstruct-0.2.3}/README.md +18 -2
- obstruct-0.2.3/src/obstruct/__version__.py +1 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/test/test_speed.py +4 -3
- obstruct-0.2.2/src/obstruct/__version__.py +0 -1
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/.gitignore +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/Hydrogenlib-Objective-Struct.iml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/misc.xml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/modules.xml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/.idea/vcs.xml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/pyproject.toml +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/__init__.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/aot/__init__.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/aot/aot.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/aot/base.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/aot/pack.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/aot/unpack.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/decorator.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/methods.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/struct_type.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/types/__init__.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/types/base.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/types/types.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/src/obstruct/types/types.pyi +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/test/test.py +0 -0
- {obstruct-0.2.2 → obstruct-0.2.3}/uv.lock +0 -0
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
7
|
<list default="true" id="b482b6b4-48ce-4be1-bf3c-a72ec254fa35" name="更改" comment="initial commit">
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/src/obstruct/__version__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/__version__.py" afterDir="false" />
|
|
9
10
|
<change beforePath="$PROJECT_DIR$/src/obstruct/aot/base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/aot/base.py" afterDir="false" />
|
|
10
11
|
<change beforePath="$PROJECT_DIR$/src/obstruct/aot/unpack.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/aot/unpack.py" afterDir="false" />
|
|
11
12
|
<change beforePath="$PROJECT_DIR$/src/obstruct/decorator.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/decorator.py" afterDir="false" />
|
|
12
13
|
<change beforePath="$PROJECT_DIR$/src/obstruct/methods.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/methods.py" afterDir="false" />
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/src/obstruct/types/types.pyi" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/types/types.pyi" afterDir="false" />
|
|
13
15
|
<change beforePath="$PROJECT_DIR$/uv.lock" beforeDir="false" afterPath="$PROJECT_DIR$/uv.lock" afterDir="false" />
|
|
14
16
|
</list>
|
|
15
17
|
<option name="SHOW_DIALOG" value="false" />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: obstruct
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Author-email: LittleNightSong <LittleNightSongYO@outlook.com>
|
|
5
5
|
Classifier: Development Status :: 3 - Alpha
|
|
6
6
|
Classifier: Programming Language :: Python
|
|
@@ -20,16 +20,31 @@ _来自已弃坑的 `Hydrogenlib`,重拾起当初的决心_
|
|
|
20
20
|
>
|
|
21
21
|
> 同时,`HydrogenLib`中的 `Objective-Struct` 不再会更新
|
|
22
22
|
|
|
23
|
+
>[!TIP]
|
|
24
|
+
> 作者的主要开发精力放在了另一些项目上,也许很长时间这个项目都不会再更新
|
|
23
25
|
|
|
24
26
|
# OBStruct
|
|
25
27
|
_一个简单、纯粹、极速的二进制解析库_
|
|
26
28
|
|
|
27
29
|
## 亮点
|
|
30
|
+
- 纯 Python
|
|
28
31
|
- 基于类型注解的字段声明方式
|
|
29
32
|
- 支持 `struct` 标准库中的所有格式,并额外支持 array 类型
|
|
30
33
|
- 基于 AOT 的加速
|
|
31
34
|
- 完整的操作支持(打包、解包、流式处理)
|
|
32
35
|
|
|
36
|
+
>[!WARNING]
|
|
37
|
+
>使用 `array` 类型将带来严重的性能损失,谨慎使用
|
|
38
|
+
|
|
39
|
+
## 基准测试
|
|
40
|
+
### 系统环境
|
|
41
|
+
- 12th Gen Intel® Core(TM) i7-12700H
|
|
42
|
+
|
|
43
|
+
在 12个字段,10000 次操作,8轮取平均值的条件下:
|
|
44
|
+
- 打包:269.639ns 一次操作
|
|
45
|
+
- 解包:582.185ns 一次操作
|
|
46
|
+
|
|
47
|
+
|
|
33
48
|
## 安装
|
|
34
49
|
```commandline
|
|
35
50
|
pip install obstruct
|
|
@@ -67,10 +82,11 @@ if __name__ == '__main__':
|
|
|
67
82
|
|
|
68
83
|
```
|
|
69
84
|
|
|
70
|
-
在上述示例中,你可能发现 `data != restored
|
|
71
|
-
|
|
85
|
+
在上述示例中,你可能发现 `data != restored`,这是浮点数的精度限制导致的。
|
|
86
|
+
因此,我们不建议使用浮点数类型,浮点数在二进制传输中也不常见。
|
|
72
87
|
|
|
73
88
|
## 计划
|
|
74
89
|
- 展平装饰器,目前的 API 较为繁琐,需要简化为唯一的 `Struct` 基类
|
|
75
90
|
- 继续优化性能
|
|
76
91
|
- 通过存根文件强制表明类型似乎变得不再有效了
|
|
92
|
+
- 支持 Tag 联合类型,对标 `msgspec`
|
|
@@ -6,16 +6,31 @@ _来自已弃坑的 `Hydrogenlib`,重拾起当初的决心_
|
|
|
6
6
|
>
|
|
7
7
|
> 同时,`HydrogenLib`中的 `Objective-Struct` 不再会更新
|
|
8
8
|
|
|
9
|
+
>[!TIP]
|
|
10
|
+
> 作者的主要开发精力放在了另一些项目上,也许很长时间这个项目都不会再更新
|
|
9
11
|
|
|
10
12
|
# OBStruct
|
|
11
13
|
_一个简单、纯粹、极速的二进制解析库_
|
|
12
14
|
|
|
13
15
|
## 亮点
|
|
16
|
+
- 纯 Python
|
|
14
17
|
- 基于类型注解的字段声明方式
|
|
15
18
|
- 支持 `struct` 标准库中的所有格式,并额外支持 array 类型
|
|
16
19
|
- 基于 AOT 的加速
|
|
17
20
|
- 完整的操作支持(打包、解包、流式处理)
|
|
18
21
|
|
|
22
|
+
>[!WARNING]
|
|
23
|
+
>使用 `array` 类型将带来严重的性能损失,谨慎使用
|
|
24
|
+
|
|
25
|
+
## 基准测试
|
|
26
|
+
### 系统环境
|
|
27
|
+
- 12th Gen Intel® Core(TM) i7-12700H
|
|
28
|
+
|
|
29
|
+
在 12个字段,10000 次操作,8轮取平均值的条件下:
|
|
30
|
+
- 打包:269.639ns 一次操作
|
|
31
|
+
- 解包:582.185ns 一次操作
|
|
32
|
+
|
|
33
|
+
|
|
19
34
|
## 安装
|
|
20
35
|
```commandline
|
|
21
36
|
pip install obstruct
|
|
@@ -53,10 +68,11 @@ if __name__ == '__main__':
|
|
|
53
68
|
|
|
54
69
|
```
|
|
55
70
|
|
|
56
|
-
在上述示例中,你可能发现 `data != restored
|
|
57
|
-
|
|
71
|
+
在上述示例中,你可能发现 `data != restored`,这是浮点数的精度限制导致的。
|
|
72
|
+
因此,我们不建议使用浮点数类型,浮点数在二进制传输中也不常见。
|
|
58
73
|
|
|
59
74
|
## 计划
|
|
60
75
|
- 展平装饰器,目前的 API 较为繁琐,需要简化为唯一的 `Struct` 基类
|
|
61
76
|
- 继续优化性能
|
|
62
77
|
- 通过存根文件强制表明类型似乎变得不再有效了
|
|
78
|
+
- 支持 Tag 联合类型,对标 `msgspec`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.2.3"
|
|
@@ -34,14 +34,15 @@ def test_timeit(name, code):
|
|
|
34
34
|
import timeit
|
|
35
35
|
|
|
36
36
|
print("Test: ", name)
|
|
37
|
-
res = timeit.
|
|
37
|
+
res = timeit.repeat(
|
|
38
38
|
code,
|
|
39
39
|
number=NUMBER,
|
|
40
|
+
repeat=8,
|
|
40
41
|
timer=time.perf_counter_ns,
|
|
41
42
|
globals=globals()
|
|
42
43
|
)
|
|
43
|
-
print(f'{NUMBER} steps finished in {res:.3f} ns')
|
|
44
|
-
print(f'Average: {res/NUMBER:.3f} ns per step', '\n\n')
|
|
44
|
+
print(f'{NUMBER} steps finished in {sum(res)/8:.3f} ns')
|
|
45
|
+
print(f'Average: {sum(res)/8/NUMBER:.3f} ns per step', '\n\n')
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
NUMBER = 10000
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|