bool-hybrid-array 7.9.0__py3-none-any.whl
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.
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bool-hybrid-array
|
|
3
|
+
Version: 7.9.0
|
|
4
|
+
Summary: 高效节省内存的混合布尔数组
|
|
5
|
+
Author: 蔡靖杰
|
|
6
|
+
Author-email: 1289270215@qq.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.21.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# BoolHybridArray:高效的布尔混合数组库
|
|
28
|
+
|
|
29
|
+
一个专为布尔值优化的数组类,能够根据数据特征自动在密集存储和稀疏存储模式间切换,兼顾性能和内存效率。
|
|
30
|
+
|
|
31
|
+
## 安装方法
|
|
32
|
+
|
|
33
|
+
使用pip安装:
|
|
34
|
+
pip install bool-hybrid-array
|
|
35
|
+
|
|
36
|
+
## 核心特性
|
|
37
|
+
|
|
38
|
+
* **智能存储模式**:数据量小的位置使用密集存储numpy.ndarray数组,
|
|
39
|
+
* 数据量大的位置为稀疏存储array.array稀疏数组
|
|
40
|
+
* 非稀疏模式:数据大部分为非0(True)索引
|
|
41
|
+
* 稀疏模式:数据大部分为0(False)索引
|
|
42
|
+
* BoolHybridArr函数会自动切换
|
|
43
|
+
* **内存高效**:稀疏数据场景下比普通列表节省50%-80%内存
|
|
44
|
+
* **操作便捷**:支持类似列表的索引、切片和赋值操作
|
|
45
|
+
* **快速统计**:内置高效的计数和布尔判断方法
|
|
46
|
+
|
|
47
|
+
## 快速开始
|
|
48
|
+
|
|
49
|
+
### 基本用法
|
|
50
|
+
|
|
51
|
+
# 导入类
|
|
52
|
+
|
|
53
|
+
from bool\_hybrid\_array import BoolHybridArr,TruesArray,FalseArray
|
|
54
|
+
|
|
55
|
+
# 创建实例
|
|
56
|
+
|
|
57
|
+
arr = BoolHybridArr(\[True, False, True, False, True])
|
|
58
|
+
|
|
59
|
+
arr2 = TruesArray(3)#7.9.0新增
|
|
60
|
+
|
|
61
|
+
arr3 = FalseArray(3)#7.9.0新增
|
|
62
|
+
|
|
63
|
+
# 访问元素
|
|
64
|
+
|
|
65
|
+
print(arr\[0]) # 输出: True
|
|
66
|
+
print(arr\[1:4]) # 输出: BoolHybridArr(\[False, True, False])
|
|
67
|
+
|
|
68
|
+
print(arr1) # 输出: BoolHybridArr(True, True, True])
|
|
69
|
+
|
|
70
|
+
print(arr2) # 输出: BoolHybridArr(\[False, False, False])
|
|
71
|
+
|
|
72
|
+
# 联系方式
|
|
73
|
+
|
|
74
|
+
* 若遇到 Bug 或有功能建议,可发送邮件至:1289270215@qq.com
|
|
75
|
+
* 微信联系:18250730129
|
|
76
|
+
|
|
77
|
+
# 修改元素
|
|
78
|
+
|
|
79
|
+
arr\[2] = False
|
|
80
|
+
print(arr) # 输出: BoolHybridArr(\[True, False, False, False, True])
|
|
81
|
+
|
|
82
|
+
### 存储优化
|
|
83
|
+
|
|
84
|
+
# 创建包含大量布尔值的数组(大部分为False)
|
|
85
|
+
|
|
86
|
+
big\_arr = BoolHybridArr(\[i % 100 == 0 for i in range(10000)])
|
|
87
|
+
|
|
88
|
+
# 查看存储模式(此时应为稀疏模式)
|
|
89
|
+
|
|
90
|
+
print(repr(big\_arr)) # 输出: BoolHybridArray(split\_index=100,size=10000,is\_sparse=True,small\_len=100,large\_len=)好吧large\_len我也不知道
|
|
91
|
+
|
|
92
|
+
# 自动优化存储
|
|
93
|
+
|
|
94
|
+
big\_arr.optimize()
|
|
95
|
+
|
|
96
|
+
### 统计功能
|
|
97
|
+
|
|
98
|
+
# 统计True的数量
|
|
99
|
+
|
|
100
|
+
print(arr.count(True)) # 输出: 2
|
|
101
|
+
|
|
102
|
+
# 检查是否至少有一个True
|
|
103
|
+
|
|
104
|
+
print(any(arr)) # 输出: True
|
|
105
|
+
|
|
106
|
+
# 检查是否全为True
|
|
107
|
+
|
|
108
|
+
print(all(arr)) # 输出: False
|
|
109
|
+
|
|
110
|
+
## 性能优势
|
|
111
|
+
|
|
112
|
+
在包含100万个布尔值且只有10%为True的场景下:
|
|
113
|
+
或在包含100万个布尔值且只有10%为False的场景下:
|
|
114
|
+
|
|
115
|
+
* 普通Python列表:约占用1MB内存
|
|
116
|
+
* BoolHybridArray:约占用100KB内存(节省90%)
|
|
117
|
+
* 随机访问速度基本保持一致
|
|
118
|
+
|
|
119
|
+
## 版本历史
|
|
120
|
+
|
|
121
|
+
* 7.8.13:PyPI上的初始版本,支持基本功能和自动存储优化
|
|
122
|
+
* 7.9.0:添加TruesArray和FalsesArray
|
|
123
|
+
|
|
124
|
+
## 许可证
|
|
125
|
+
|
|
126
|
+
本项目采用MIT许可证,详情参见LICENSE文件。
|
|
127
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
bool_hybrid_array-7.9.0.dist-info/licenses/LICENSE,sha256=Sg4rnGXkBDYkwJCWyxdWp5H60rhVAxpNvFh_l3JWZdY,1070
|
|
2
|
+
bool_hybrid_array-7.9.0.dist-info/METADATA,sha256=7JL8JSCDjB6b9A1kp4RmVK9xQRePS3XhDCEsabdGCpI,3519
|
|
3
|
+
bool_hybrid_array-7.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
4
|
+
bool_hybrid_array-7.9.0.dist-info/top_level.txt,sha256=vk-TD77wuVQsN1rJ6uVWZX4sC_wya_WplRDwQKJoBZM,18
|
|
5
|
+
bool_hybrid_array-7.9.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 蔡靖杰
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bool_hybrid_array
|