xloft 0.4.7__py3-none-any.whl → 0.5.1__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.
Potentially problematic release.
This version of xloft might be problematic. Click here for more details.
- xloft/__init__.py +1 -2
- {xloft-0.4.7.dist-info → xloft-0.5.1.dist-info}/METADATA +13 -22
- xloft-0.5.1.dist-info/RECORD +9 -0
- xloft/quantum.py +0 -132
- xloft-0.4.7.dist-info/RECORD +0 -10
- {xloft-0.4.7.dist-info → xloft-0.5.1.dist-info}/WHEEL +0 -0
- {xloft-0.4.7.dist-info → xloft-0.5.1.dist-info}/licenses/LICENSE +0 -0
xloft/__init__.py
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Modules exported by this package:
|
|
4
4
|
|
|
5
|
-
- `namedtuple
|
|
5
|
+
- `namedtuple`- Class imitates the behavior of the _named tuple_.
|
|
6
6
|
- `human` - A collection of instruments for converting data to format is convenient for humans.
|
|
7
|
-
- `quantum` - A set of tools for quantum calculations.
|
|
8
7
|
"""
|
|
9
8
|
|
|
10
9
|
from __future__ import annotations
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xloft
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: (XLOFT) X-Library of tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/xloft
|
|
6
6
|
Project-URL: Repository, https://github.com/kebasyaty/xloft
|
|
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
24
24
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
26
|
Classifier: Topic :: Utilities
|
|
26
27
|
Classifier: Typing :: Typed
|
|
27
28
|
Requires-Python: <4.0,>=3.12
|
|
@@ -60,7 +61,8 @@ Description-Content-Type: text/markdown
|
|
|
60
61
|
<a href="https://github.com/kebasyaty/xloft/releases/" alt="GitHub release"><img src="https://img.shields.io/github/release/kebasyaty/xloft" alt="GitHub release"></a>
|
|
61
62
|
</p>
|
|
62
63
|
<p align="center">
|
|
63
|
-
The collection is represented by three modules of `NamedTuple`, `Human
|
|
64
|
+
The collection is represented by three modules of `NamedTuple`, `Human`.
|
|
65
|
+
<br>
|
|
64
66
|
In the future, new tools can be added.
|
|
65
67
|
</p>
|
|
66
68
|
</p>
|
|
@@ -68,6 +70,15 @@ Description-Content-Type: text/markdown
|
|
|
68
70
|
|
|
69
71
|
##
|
|
70
72
|
|
|
73
|
+
<img src="https://raw.githubusercontent.com/kebasyaty/xloft/v0/assets/attention.svg" alt="Attention">
|
|
74
|
+
<p>
|
|
75
|
+
The `quantum` module was deleted.
|
|
76
|
+
<br>
|
|
77
|
+
<a href="https://pypi.python.org/pypi/quantum-loop/" alt="quantum-loop">He is now here</a>
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
<br>
|
|
81
|
+
|
|
71
82
|
## Documentation
|
|
72
83
|
|
|
73
84
|
Online browsable documentation is available at [https://kebasyaty.github.io/xloft/](https://kebasyaty.github.io/xloft/ "Documentation").
|
|
@@ -170,26 +181,6 @@ s = to_human_size(1048575)
|
|
|
170
181
|
print(s) # => 1023.999 KB
|
|
171
182
|
```
|
|
172
183
|
|
|
173
|
-
- **Quantum**
|
|
174
|
-
|
|
175
|
-
```python
|
|
176
|
-
from xloft.quantum import LoopMode, QuantumLoop, count_qubits
|
|
177
|
-
|
|
178
|
-
# Counting the number of conceptual qubits of your computer.
|
|
179
|
-
num = count_qubits()
|
|
180
|
-
print(num) # => 16
|
|
181
|
-
|
|
182
|
-
def task(item):
|
|
183
|
-
"""Quantum."""
|
|
184
|
-
return item * item
|
|
185
|
-
|
|
186
|
-
data = range(10)
|
|
187
|
-
|
|
188
|
-
# Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
189
|
-
results = QuantumLoop(task, data).run()
|
|
190
|
-
print(results) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
191
|
-
```
|
|
192
|
-
|
|
193
184
|
## Changelog
|
|
194
185
|
|
|
195
186
|
[View the change history.](https://github.com/kebasyaty/xloft/blob/main/CHANGELOG.md "Changelog")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
xloft/__init__.py,sha256=mf6z2-Tnl-CdYMa8mrI5MlTl48G0GQoYNNj2PMp8SsQ,419
|
|
2
|
+
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
+
xloft/human.py,sha256=WQbVOKpOvzGot-c7f3xitbS05JUIQmj3dreGtRV6GA0,1792
|
|
4
|
+
xloft/namedtuple.py,sha256=a_l3bZF-L2I7MGxuF2CXzAHgNai-Vyj6SY1ODwxs7TU,6856
|
|
5
|
+
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
xloft-0.5.1.dist-info/METADATA,sha256=o24kZAXLE4z4CaUnpSlqLbl-JihkCc0eXsP4mLsZQ-M,7079
|
|
7
|
+
xloft-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
xloft-0.5.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
9
|
+
xloft-0.5.1.dist-info/RECORD,,
|
xloft/quantum.py
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"""A set of tools for quantum calculations.
|
|
2
|
-
|
|
3
|
-
A Qubit in a regular computer is quantum of algorithm that is executed in
|
|
4
|
-
one iteration of a cycle in a separate processor thread.
|
|
5
|
-
|
|
6
|
-
Quantum is a function with an algorithm of task for data processing.
|
|
7
|
-
|
|
8
|
-
In this case, the Qubit is not a single information,
|
|
9
|
-
but it is a concept of the principle of operation of quantum calculations on a regular computer.
|
|
10
|
-
|
|
11
|
-
The module contains the following tools:
|
|
12
|
-
|
|
13
|
-
- `LoopMode` - Quantum loop mode.
|
|
14
|
-
- `count_qubits()` - Counting the number of conceptual qubits of your computer.
|
|
15
|
-
- `QuantumLoop` - Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
from __future__ import annotations
|
|
19
|
-
|
|
20
|
-
import concurrent.futures
|
|
21
|
-
import multiprocessing
|
|
22
|
-
from collections.abc import Callable, Iterable
|
|
23
|
-
from enum import Enum
|
|
24
|
-
from typing import Any, Never, assert_never
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class LoopMode(Enum):
|
|
28
|
-
"""Quantum loop mode."""
|
|
29
|
-
|
|
30
|
-
PROCESS_POOL = 1
|
|
31
|
-
THREAD_POOL = 2
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def count_qubits() -> int:
|
|
35
|
-
"""Counting the number of conceptual qubits of your computer.
|
|
36
|
-
|
|
37
|
-
Conceptual qubit is quantum of algorithm (task) that is executed in
|
|
38
|
-
iterations of a cycle in a separate processor thread.
|
|
39
|
-
|
|
40
|
-
Quantum of algorithm is a function for data processing.
|
|
41
|
-
|
|
42
|
-
Examples:
|
|
43
|
-
>>> from xloft.quantum import count_qubits
|
|
44
|
-
>>> count_qubits()
|
|
45
|
-
16
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
The number of conceptual qubits.
|
|
49
|
-
"""
|
|
50
|
-
return multiprocessing.cpu_count()
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class QuantumLoop:
|
|
54
|
-
"""Separation of the cycle into quantum algorithms for multiprocessing data processing.
|
|
55
|
-
|
|
56
|
-
Examples:
|
|
57
|
-
>>> from xloft.quantum import QuantumLoop
|
|
58
|
-
>>> def task(item):
|
|
59
|
-
... return item * item
|
|
60
|
-
>>> data = range(10)
|
|
61
|
-
>>> QuantumLoop(task, data).run()
|
|
62
|
-
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
|
63
|
-
|
|
64
|
-
Args:
|
|
65
|
-
task: Function with a task algorithm.
|
|
66
|
-
data: The data that needs to be processed.
|
|
67
|
-
max_workers: The maximum number of processes that can be used to
|
|
68
|
-
execute the given calls. If None or not given then as many
|
|
69
|
-
worker processes will be created as the machine has processors.
|
|
70
|
-
timeout: The maximum number of seconds to wait. If None, then there
|
|
71
|
-
is no limit on the wait time.
|
|
72
|
-
chunksize: The size of the chunks the iterable will be broken into
|
|
73
|
-
before being passed to a child process. This argument is only
|
|
74
|
-
used by ProcessPoolExecutor; it is ignored by ThreadPoolExecutor.
|
|
75
|
-
mode: The operating mode for a quantum loop: LoopMode.PROCESS_POOL | LoopMode.THREAD_POOL.
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
def __init__( # noqa: D107
|
|
79
|
-
self,
|
|
80
|
-
task: Callable,
|
|
81
|
-
data: Iterable[Any],
|
|
82
|
-
max_workers: int | None = None,
|
|
83
|
-
timeout: float | None = None,
|
|
84
|
-
chunksize: int = 1,
|
|
85
|
-
mode: LoopMode = LoopMode.PROCESS_POOL,
|
|
86
|
-
) -> None:
|
|
87
|
-
self.quantum = task
|
|
88
|
-
self.data = data
|
|
89
|
-
self.max_workers = max_workers
|
|
90
|
-
self.timeout = timeout
|
|
91
|
-
self.chunksize = chunksize
|
|
92
|
-
self.mode = mode
|
|
93
|
-
|
|
94
|
-
def process_pool(self) -> list[Any]:
|
|
95
|
-
"""Better suitable for operations for which large processor resources are required."""
|
|
96
|
-
with concurrent.futures.ProcessPoolExecutor(self.max_workers) as executor:
|
|
97
|
-
results = list(
|
|
98
|
-
executor.map(
|
|
99
|
-
self.quantum,
|
|
100
|
-
self.data,
|
|
101
|
-
timeout=self.timeout,
|
|
102
|
-
chunksize=self.chunksize,
|
|
103
|
-
),
|
|
104
|
-
)
|
|
105
|
-
return results # noqa: RET504
|
|
106
|
-
|
|
107
|
-
def thread_pool(self) -> list[Any]:
|
|
108
|
-
"""More suitable for tasks related to input-output
|
|
109
|
-
(for example, network queries, file operations),
|
|
110
|
-
where GIL is freed during input-output operations.""" # noqa: D205, D209
|
|
111
|
-
with concurrent.futures.ThreadPoolExecutor(self.max_workers) as executor:
|
|
112
|
-
results = list(
|
|
113
|
-
executor.map(
|
|
114
|
-
self.quantum,
|
|
115
|
-
self.data,
|
|
116
|
-
timeout=self.timeout,
|
|
117
|
-
chunksize=self.chunksize,
|
|
118
|
-
),
|
|
119
|
-
)
|
|
120
|
-
return results # noqa: RET504
|
|
121
|
-
|
|
122
|
-
def run(self) -> list[Any]:
|
|
123
|
-
"""Run the quantum loop."""
|
|
124
|
-
results: list[Any] = []
|
|
125
|
-
match self.mode.value:
|
|
126
|
-
case 1:
|
|
127
|
-
results = self.process_pool()
|
|
128
|
-
case 2:
|
|
129
|
-
results = self.thread_pool()
|
|
130
|
-
case _ as unreachable:
|
|
131
|
-
assert_never(Never(unreachable))
|
|
132
|
-
return results
|
xloft-0.4.7.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
xloft/__init__.py,sha256=UL4IR8EcFjgWoQFayl6FrK2u8QmZytGCwa_E1jDiCmE,475
|
|
2
|
-
xloft/errors.py,sha256=hZcmF0QVVdvE5oM1jsXymRk_pPGgDSnUDM9wx9zJAYQ,895
|
|
3
|
-
xloft/human.py,sha256=WQbVOKpOvzGot-c7f3xitbS05JUIQmj3dreGtRV6GA0,1792
|
|
4
|
-
xloft/namedtuple.py,sha256=a_l3bZF-L2I7MGxuF2CXzAHgNai-Vyj6SY1ODwxs7TU,6856
|
|
5
|
-
xloft/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xloft/quantum.py,sha256=ZkFqqFROC9j5JbwJmej3yL9VJcqElPrrimFTz0Pe3Mk,4679
|
|
7
|
-
xloft-0.4.7.dist-info/METADATA,sha256=n2eO_R6lJ7VedihIUh4TiLYdDS9CaJR36hQxZyxpYw4,7241
|
|
8
|
-
xloft-0.4.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
xloft-0.4.7.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
|
|
10
|
-
xloft-0.4.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|