pyroid 0.2.7__tar.gz → 0.2.8__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.
- {pyroid-0.2.7 → pyroid-0.2.8}/Cargo.lock +1 -1
- {pyroid-0.2.7 → pyroid-0.2.8}/Cargo.toml +15 -3
- {pyroid-0.2.7 → pyroid-0.2.8}/PKG-INFO +50 -65
- {pyroid-0.2.7 → pyroid-0.2.8}/README.md +49 -64
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/README.md +40 -5
- pyroid-0.2.8/docs/api/dataframe_ops.md +256 -0
- pyroid-0.2.8/docs/api/image_ops.md +473 -0
- pyroid-0.2.8/docs/api/index.md +219 -0
- pyroid-0.2.8/docs/api/io_ops.md +338 -0
- pyroid-0.2.8/docs/api/ml_ops.md +377 -0
- pyroid-0.2.8/docs/api/text_nlp_ops.md +518 -0
- pyroid-0.2.8/docs/guides/getting_started.md +225 -0
- pyroid-0.2.8/docs/guides/index.md +36 -0
- pyroid-0.2.8/docs/guides/performance.md +163 -0
- pyroid-0.2.8/docs/index.md +168 -0
- pyroid-0.2.8/examples/async_examples.py +166 -0
- pyroid-0.2.8/examples/data_examples.py +135 -0
- pyroid-0.2.8/examples/dataframe_examples.py +140 -0
- pyroid-0.2.8/examples/image_examples.py +151 -0
- pyroid-0.2.8/examples/io_examples.py +128 -0
- pyroid-0.2.8/examples/math_examples.py +155 -0
- pyroid-0.2.8/examples/ml_examples.py +170 -0
- pyroid-0.2.8/examples/requirements.txt +5 -0
- pyroid-0.2.8/examples/string_examples.py +118 -0
- pyroid-0.2.8/examples/test_async_file.txt +3 -0
- pyroid-0.2.8/examples/text_nlp_examples.py +169 -0
- pyroid-0.2.8/pyproject.toml +78 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/__init__.py +3 -1
- pyroid-0.2.8/python/pyroid/string/__init__.py +47 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/text/__init__.py +16 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/setup.py +3 -2
- {pyroid-0.2.7 → pyroid-0.2.8}/src/core/types.rs +3 -3
- {pyroid-0.2.7 → pyroid-0.2.8}/src/io/file.rs +2 -2
- pyroid-0.2.8/test_pyroid.py +334 -0
- pyroid-0.2.7/benchmarks/README_update.md +0 -46
- pyroid-0.2.7/benchmarks/benchmark_plan.md +0 -216
- pyroid-0.2.7/benchmarks/generate_notebook.py +0 -35
- pyroid-0.2.7/benchmarks/pyroid_benchmarks.ipynb +0 -1133
- pyroid-0.2.7/docs/api/dataframe_ops.md +0 -382
- pyroid-0.2.7/docs/api/image_ops.md +0 -274
- pyroid-0.2.7/docs/api/index.md +0 -139
- pyroid-0.2.7/docs/api/io_ops.md +0 -702
- pyroid-0.2.7/docs/api/ml_ops.md +0 -389
- pyroid-0.2.7/docs/api/text_nlp_ops.md +0 -507
- pyroid-0.2.7/docs/guides/getting_started.md +0 -427
- pyroid-0.2.7/docs/guides/index.md +0 -100
- pyroid-0.2.7/docs/guides/performance.md +0 -559
- pyroid-0.2.7/docs/index.md +0 -206
- pyroid-0.2.7/examples/async_examples.py +0 -138
- pyroid-0.2.7/examples/data_examples.py +0 -69
- pyroid-0.2.7/examples/dataframe_examples.py +0 -154
- pyroid-0.2.7/examples/image_examples.py +0 -180
- pyroid-0.2.7/examples/io_examples.py +0 -173
- pyroid-0.2.7/examples/math_examples.py +0 -102
- pyroid-0.2.7/examples/ml_examples.py +0 -202
- pyroid-0.2.7/examples/requirements.txt +0 -11
- pyroid-0.2.7/examples/string_examples.py +0 -74
- pyroid-0.2.7/examples/test_async_file.txt +0 -3
- pyroid-0.2.7/examples/text_nlp_examples.py +0 -136
- pyroid-0.2.7/pyproject.toml +0 -76
- pyroid-0.2.7/test_pyroid.py +0 -72
- {pyroid-0.2.7 → pyroid-0.2.8}/.github/workflows/publish.yml +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/.github/workflows/semantic-release.yml +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/.gitignore +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/core/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/core/benchmark.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/core/reporter.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/core/visualizer.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/demo.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/run_benchmarks.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/async_benchmarks.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/data_benchmarks.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/math_benchmarks.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/scenarios/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/scenarios/data_pipeline.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/scenarios/scientific_computing.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/scenarios/text_processing.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/scenarios/web_scraping.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/benchmarks/suites/string_benchmarks.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/build.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/core/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/data/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/image/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/image/basic/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/io/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/math/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/math/stats.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/ml/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/pyroid/ml/basic/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/tests/__init__.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/python/tests/test_basic.py +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/async_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/core/config.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/core/conversion.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/core/error.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/core/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/data/collections.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/data/dataframe.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/data/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/data_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/dataframe_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/image/basic.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/image/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/image_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/io/async_io.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/io/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/io/network.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/io_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/lib.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/math/matrix.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/math/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/math/stats.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/math/vector.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/math_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/ml/basic.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/ml/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/ml_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/string_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/text/mod.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/text_nlp_ops.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/utils/conversions.rs +0 -0
- {pyroid-0.2.7 → pyroid-0.2.8}/src/utils/mod.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "pyroid"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.8"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
authors = ["Andrew O", "Pyroid Team"]
|
|
6
6
|
description = "High-performance Rust functions for Python"
|
|
@@ -24,13 +24,24 @@ ml = []
|
|
|
24
24
|
|
|
25
25
|
[dependencies]
|
|
26
26
|
# Core dependencies
|
|
27
|
-
pyo3 = { version = "0.20.0", features = [
|
|
27
|
+
pyo3 = { version = "0.20.0", features = [
|
|
28
|
+
"extension-module",
|
|
29
|
+
"auto-initialize",
|
|
30
|
+
"abi3-py38",
|
|
31
|
+
] }
|
|
28
32
|
rayon = "1.10.0"
|
|
29
33
|
serde_json = "1.0.114"
|
|
30
34
|
num_cpus = "1.16.0"
|
|
31
35
|
|
|
32
36
|
# Optional dependencies based on features
|
|
33
|
-
tokio = { version = "1.44.1", features = [
|
|
37
|
+
tokio = { version = "1.44.1", features = [
|
|
38
|
+
"rt",
|
|
39
|
+
"rt-multi-thread",
|
|
40
|
+
"macros",
|
|
41
|
+
"io-util",
|
|
42
|
+
"fs",
|
|
43
|
+
"time",
|
|
44
|
+
], optional = true }
|
|
34
45
|
futures = { version = "0.3.31", optional = true }
|
|
35
46
|
regex = { version = "1.10.3", optional = true }
|
|
36
47
|
|
|
@@ -53,3 +64,4 @@ strip = true
|
|
|
53
64
|
[profile.dev]
|
|
54
65
|
opt-level = 0
|
|
55
66
|
debug = true
|
|
67
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyroid
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3.8
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -151,13 +151,13 @@ import pyroid
|
|
|
151
151
|
|
|
152
152
|
# Basic string operations
|
|
153
153
|
text = "Hello, world!"
|
|
154
|
-
reversed_text = pyroid.
|
|
155
|
-
uppercase = pyroid.
|
|
156
|
-
lowercase = pyroid.
|
|
154
|
+
reversed_text = pyroid.text.reverse(text)
|
|
155
|
+
uppercase = pyroid.text.to_uppercase(text)
|
|
156
|
+
lowercase = pyroid.text.to_lowercase(text)
|
|
157
157
|
|
|
158
158
|
# Base64 encoding/decoding
|
|
159
|
-
encoded = pyroid.
|
|
160
|
-
decoded = pyroid.
|
|
159
|
+
encoded = pyroid.text.base64_encode(text)
|
|
160
|
+
decoded = pyroid.text.base64_decode(encoded)
|
|
161
161
|
print(f"Original: {text}")
|
|
162
162
|
print(f"Encoded: {encoded}")
|
|
163
163
|
print(f"Decoded: {decoded}")
|
|
@@ -168,24 +168,21 @@ print(f"Decoded: {decoded}")
|
|
|
168
168
|
```python
|
|
169
169
|
import pyroid
|
|
170
170
|
|
|
171
|
-
# Create a
|
|
172
|
-
df = {
|
|
173
|
-
'
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
# Create a DataFrame object
|
|
179
|
-
dataframe = pyroid.data.dataframe.PyDataFrame(df)
|
|
171
|
+
# Create a DataFrame
|
|
172
|
+
df = pyroid.data.DataFrame({
|
|
173
|
+
'id': [1, 2, 3, 4, 5],
|
|
174
|
+
'name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
|
|
175
|
+
'age': [25, 30, 35, 40, 45]
|
|
176
|
+
})
|
|
180
177
|
|
|
181
178
|
# Apply a function to each column
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
result = pyroid.data.apply(df, lambda x: x * 2, axis=0)
|
|
180
|
+
print(f"DataFrame: {df}")
|
|
181
|
+
print(f"Applied function: {result}")
|
|
184
182
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
print(f"
|
|
188
|
-
print(f"Result: {result.to_dict()}")
|
|
183
|
+
# Group by and aggregate
|
|
184
|
+
grouped = pyroid.data.groupby_aggregate(df, "age", {"name": "count"})
|
|
185
|
+
print(f"Grouped by age: {grouped}")
|
|
189
186
|
```
|
|
190
187
|
|
|
191
188
|
### Collection Operations
|
|
@@ -195,21 +192,21 @@ import pyroid
|
|
|
195
192
|
|
|
196
193
|
# Filter a list
|
|
197
194
|
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
198
|
-
even_numbers = pyroid.data.
|
|
195
|
+
even_numbers = pyroid.data.filter(numbers, lambda x: x % 2 == 0)
|
|
199
196
|
print(f"Even numbers: {even_numbers}")
|
|
200
197
|
|
|
201
198
|
# Map a function over a list
|
|
202
|
-
squared = pyroid.data.
|
|
199
|
+
squared = pyroid.data.map(numbers, lambda x: x * x)
|
|
203
200
|
print(f"Squared numbers: {squared}")
|
|
204
201
|
|
|
205
202
|
# Reduce a list
|
|
206
|
-
sum_result = pyroid.data.
|
|
203
|
+
sum_result = pyroid.data.reduce(numbers, lambda x, y: x + y)
|
|
207
204
|
print(f"Sum: {sum_result}")
|
|
208
205
|
|
|
209
206
|
# Sort a list
|
|
210
207
|
unsorted = [5, 2, 8, 1, 9, 3]
|
|
211
|
-
sorted_list = pyroid.data.
|
|
212
|
-
print(f"Sorted: {sorted_list}")
|
|
208
|
+
sorted_list = pyroid.data.sort(unsorted, reverse=True) # Note: supports reverse parameter
|
|
209
|
+
print(f"Sorted (descending): {sorted_list}")
|
|
213
210
|
```
|
|
214
211
|
|
|
215
212
|
### File I/O Operations
|
|
@@ -218,17 +215,16 @@ print(f"Sorted: {sorted_list}")
|
|
|
218
215
|
import pyroid
|
|
219
216
|
|
|
220
217
|
# Read a file
|
|
221
|
-
content = pyroid.io.
|
|
218
|
+
content = pyroid.io.read_file("example.txt")
|
|
222
219
|
print(f"File content length: {len(content)}")
|
|
223
220
|
|
|
224
221
|
# Write a file
|
|
225
|
-
pyroid.io.
|
|
222
|
+
pyroid.io.write_file("output.txt", "Hello, world!") # Note: string, not bytes
|
|
226
223
|
|
|
227
224
|
# Read multiple files
|
|
228
225
|
files = ["file1.txt", "file2.txt", "file3.txt"]
|
|
229
|
-
contents = pyroid.io.
|
|
230
|
-
|
|
231
|
-
print(f"{file}: {len(content)} bytes")
|
|
226
|
+
contents = pyroid.io.read_files(files)
|
|
227
|
+
print(f"Read multiple files: {contents}")
|
|
232
228
|
```
|
|
233
229
|
|
|
234
230
|
### Network Operations
|
|
@@ -237,14 +233,11 @@ for file, content in contents.items():
|
|
|
237
233
|
import pyroid
|
|
238
234
|
|
|
239
235
|
# Make a GET request
|
|
240
|
-
response = pyroid.io.
|
|
241
|
-
print(f"
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
#
|
|
245
|
-
data = {"name": "John", "age": 30}
|
|
246
|
-
response = pyroid.io.network.post("https://example.com/api", json=data)
|
|
247
|
-
print(f"Status: {response['status']}")
|
|
236
|
+
response = pyroid.io.get("https://example.com")
|
|
237
|
+
print(f"HTTP GET response length: {len(response)}")
|
|
238
|
+
|
|
239
|
+
# Note: POST requests might not be implemented in the current version
|
|
240
|
+
# If you need to make POST requests, check the documentation for the latest API
|
|
248
241
|
```
|
|
249
242
|
|
|
250
243
|
### Async Operations
|
|
@@ -256,22 +249,15 @@ import pyroid
|
|
|
256
249
|
async def main():
|
|
257
250
|
# Async sleep
|
|
258
251
|
print("Sleeping for 1 second...")
|
|
259
|
-
await pyroid.io.
|
|
252
|
+
await pyroid.io.sleep(0.1)
|
|
260
253
|
print("Awake!")
|
|
261
254
|
|
|
262
255
|
# Async file operations
|
|
263
|
-
await pyroid.io.
|
|
264
|
-
content = await pyroid.io.async_io.read_file_async("async_test.txt")
|
|
256
|
+
content = await pyroid.io.read_file_async("example.txt")
|
|
265
257
|
print(f"File content: {content}")
|
|
266
258
|
|
|
267
|
-
#
|
|
268
|
-
|
|
269
|
-
print(f"Response length: {len(response)}")
|
|
270
|
-
|
|
271
|
-
# Async HTTP POST
|
|
272
|
-
data = {"name": "John", "age": 30}
|
|
273
|
-
response = await pyroid.io.async_io.http_post_async("https://example.com/api", json=data)
|
|
274
|
-
print(f"Response length: {len(response)}")
|
|
259
|
+
# Note: Other async operations might not be fully implemented
|
|
260
|
+
# in the current version. Check the documentation for the latest API.
|
|
275
261
|
|
|
276
262
|
# Run the async main function
|
|
277
263
|
asyncio.run(main())
|
|
@@ -317,27 +303,26 @@ data = [
|
|
|
317
303
|
[1.0, 2.0], [1.5, 1.8], [5.0, 8.0],
|
|
318
304
|
[8.0, 8.0], [1.0, 0.6], [9.0, 11.0]
|
|
319
305
|
]
|
|
320
|
-
|
|
321
|
-
print(f"
|
|
322
|
-
print(f"
|
|
306
|
+
kmeans_result = pyroid.ml.basic.kmeans(data, k=2)
|
|
307
|
+
print(f"K-means centroids: {kmeans_result['centroids']}")
|
|
308
|
+
print(f"K-means clusters: {kmeans_result['clusters']}")
|
|
323
309
|
|
|
324
310
|
# Linear regression
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
print(f"
|
|
330
|
-
print(f"
|
|
311
|
+
# Note: Linear regression expects X as 2D array and y as 1D array
|
|
312
|
+
X = [[1, 1], [1, 2], [2, 2], [2, 3]]
|
|
313
|
+
y = [6, 8, 9, 11]
|
|
314
|
+
regression_result = pyroid.ml.basic.linear_regression(X, y)
|
|
315
|
+
print(f"Linear regression coefficients: {regression_result['coefficients']}")
|
|
316
|
+
print(f"Linear regression intercept: {regression_result['intercept']}")
|
|
317
|
+
print(f"Linear regression R-squared: {regression_result['r_squared']}")
|
|
331
318
|
|
|
332
319
|
# Data normalization
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
print(f"Normalized (min-max): {normalized}")
|
|
320
|
+
normalized_data = pyroid.ml.basic.normalize(data, method="min-max")
|
|
321
|
+
print(f"Normalized data (min-max): {normalized_data}")
|
|
336
322
|
|
|
337
323
|
# Distance matrix
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
print(f"Distance matrix: {distances}")
|
|
324
|
+
distance_matrix = pyroid.ml.basic.distance_matrix(data, metric="euclidean")
|
|
325
|
+
print(f"Distance matrix shape: {len(distance_matrix)}x{len(distance_matrix[0])}")
|
|
341
326
|
```
|
|
342
327
|
|
|
343
328
|
## 📊 Performance Considerations
|
|
@@ -127,13 +127,13 @@ import pyroid
|
|
|
127
127
|
|
|
128
128
|
# Basic string operations
|
|
129
129
|
text = "Hello, world!"
|
|
130
|
-
reversed_text = pyroid.
|
|
131
|
-
uppercase = pyroid.
|
|
132
|
-
lowercase = pyroid.
|
|
130
|
+
reversed_text = pyroid.text.reverse(text)
|
|
131
|
+
uppercase = pyroid.text.to_uppercase(text)
|
|
132
|
+
lowercase = pyroid.text.to_lowercase(text)
|
|
133
133
|
|
|
134
134
|
# Base64 encoding/decoding
|
|
135
|
-
encoded = pyroid.
|
|
136
|
-
decoded = pyroid.
|
|
135
|
+
encoded = pyroid.text.base64_encode(text)
|
|
136
|
+
decoded = pyroid.text.base64_decode(encoded)
|
|
137
137
|
print(f"Original: {text}")
|
|
138
138
|
print(f"Encoded: {encoded}")
|
|
139
139
|
print(f"Decoded: {decoded}")
|
|
@@ -144,24 +144,21 @@ print(f"Decoded: {decoded}")
|
|
|
144
144
|
```python
|
|
145
145
|
import pyroid
|
|
146
146
|
|
|
147
|
-
# Create a
|
|
148
|
-
df = {
|
|
149
|
-
'
|
|
150
|
-
'
|
|
151
|
-
'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
# Create a DataFrame object
|
|
155
|
-
dataframe = pyroid.data.dataframe.PyDataFrame(df)
|
|
147
|
+
# Create a DataFrame
|
|
148
|
+
df = pyroid.data.DataFrame({
|
|
149
|
+
'id': [1, 2, 3, 4, 5],
|
|
150
|
+
'name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
|
|
151
|
+
'age': [25, 30, 35, 40, 45]
|
|
152
|
+
})
|
|
156
153
|
|
|
157
154
|
# Apply a function to each column
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
result = pyroid.data.apply(df, lambda x: x * 2, axis=0)
|
|
156
|
+
print(f"DataFrame: {df}")
|
|
157
|
+
print(f"Applied function: {result}")
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
print(f"
|
|
164
|
-
print(f"Result: {result.to_dict()}")
|
|
159
|
+
# Group by and aggregate
|
|
160
|
+
grouped = pyroid.data.groupby_aggregate(df, "age", {"name": "count"})
|
|
161
|
+
print(f"Grouped by age: {grouped}")
|
|
165
162
|
```
|
|
166
163
|
|
|
167
164
|
### Collection Operations
|
|
@@ -171,21 +168,21 @@ import pyroid
|
|
|
171
168
|
|
|
172
169
|
# Filter a list
|
|
173
170
|
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
174
|
-
even_numbers = pyroid.data.
|
|
171
|
+
even_numbers = pyroid.data.filter(numbers, lambda x: x % 2 == 0)
|
|
175
172
|
print(f"Even numbers: {even_numbers}")
|
|
176
173
|
|
|
177
174
|
# Map a function over a list
|
|
178
|
-
squared = pyroid.data.
|
|
175
|
+
squared = pyroid.data.map(numbers, lambda x: x * x)
|
|
179
176
|
print(f"Squared numbers: {squared}")
|
|
180
177
|
|
|
181
178
|
# Reduce a list
|
|
182
|
-
sum_result = pyroid.data.
|
|
179
|
+
sum_result = pyroid.data.reduce(numbers, lambda x, y: x + y)
|
|
183
180
|
print(f"Sum: {sum_result}")
|
|
184
181
|
|
|
185
182
|
# Sort a list
|
|
186
183
|
unsorted = [5, 2, 8, 1, 9, 3]
|
|
187
|
-
sorted_list = pyroid.data.
|
|
188
|
-
print(f"Sorted: {sorted_list}")
|
|
184
|
+
sorted_list = pyroid.data.sort(unsorted, reverse=True) # Note: supports reverse parameter
|
|
185
|
+
print(f"Sorted (descending): {sorted_list}")
|
|
189
186
|
```
|
|
190
187
|
|
|
191
188
|
### File I/O Operations
|
|
@@ -194,17 +191,16 @@ print(f"Sorted: {sorted_list}")
|
|
|
194
191
|
import pyroid
|
|
195
192
|
|
|
196
193
|
# Read a file
|
|
197
|
-
content = pyroid.io.
|
|
194
|
+
content = pyroid.io.read_file("example.txt")
|
|
198
195
|
print(f"File content length: {len(content)}")
|
|
199
196
|
|
|
200
197
|
# Write a file
|
|
201
|
-
pyroid.io.
|
|
198
|
+
pyroid.io.write_file("output.txt", "Hello, world!") # Note: string, not bytes
|
|
202
199
|
|
|
203
200
|
# Read multiple files
|
|
204
201
|
files = ["file1.txt", "file2.txt", "file3.txt"]
|
|
205
|
-
contents = pyroid.io.
|
|
206
|
-
|
|
207
|
-
print(f"{file}: {len(content)} bytes")
|
|
202
|
+
contents = pyroid.io.read_files(files)
|
|
203
|
+
print(f"Read multiple files: {contents}")
|
|
208
204
|
```
|
|
209
205
|
|
|
210
206
|
### Network Operations
|
|
@@ -213,14 +209,11 @@ for file, content in contents.items():
|
|
|
213
209
|
import pyroid
|
|
214
210
|
|
|
215
211
|
# Make a GET request
|
|
216
|
-
response = pyroid.io.
|
|
217
|
-
print(f"
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
#
|
|
221
|
-
data = {"name": "John", "age": 30}
|
|
222
|
-
response = pyroid.io.network.post("https://example.com/api", json=data)
|
|
223
|
-
print(f"Status: {response['status']}")
|
|
212
|
+
response = pyroid.io.get("https://example.com")
|
|
213
|
+
print(f"HTTP GET response length: {len(response)}")
|
|
214
|
+
|
|
215
|
+
# Note: POST requests might not be implemented in the current version
|
|
216
|
+
# If you need to make POST requests, check the documentation for the latest API
|
|
224
217
|
```
|
|
225
218
|
|
|
226
219
|
### Async Operations
|
|
@@ -232,22 +225,15 @@ import pyroid
|
|
|
232
225
|
async def main():
|
|
233
226
|
# Async sleep
|
|
234
227
|
print("Sleeping for 1 second...")
|
|
235
|
-
await pyroid.io.
|
|
228
|
+
await pyroid.io.sleep(0.1)
|
|
236
229
|
print("Awake!")
|
|
237
230
|
|
|
238
231
|
# Async file operations
|
|
239
|
-
await pyroid.io.
|
|
240
|
-
content = await pyroid.io.async_io.read_file_async("async_test.txt")
|
|
232
|
+
content = await pyroid.io.read_file_async("example.txt")
|
|
241
233
|
print(f"File content: {content}")
|
|
242
234
|
|
|
243
|
-
#
|
|
244
|
-
|
|
245
|
-
print(f"Response length: {len(response)}")
|
|
246
|
-
|
|
247
|
-
# Async HTTP POST
|
|
248
|
-
data = {"name": "John", "age": 30}
|
|
249
|
-
response = await pyroid.io.async_io.http_post_async("https://example.com/api", json=data)
|
|
250
|
-
print(f"Response length: {len(response)}")
|
|
235
|
+
# Note: Other async operations might not be fully implemented
|
|
236
|
+
# in the current version. Check the documentation for the latest API.
|
|
251
237
|
|
|
252
238
|
# Run the async main function
|
|
253
239
|
asyncio.run(main())
|
|
@@ -293,27 +279,26 @@ data = [
|
|
|
293
279
|
[1.0, 2.0], [1.5, 1.8], [5.0, 8.0],
|
|
294
280
|
[8.0, 8.0], [1.0, 0.6], [9.0, 11.0]
|
|
295
281
|
]
|
|
296
|
-
|
|
297
|
-
print(f"
|
|
298
|
-
print(f"
|
|
282
|
+
kmeans_result = pyroid.ml.basic.kmeans(data, k=2)
|
|
283
|
+
print(f"K-means centroids: {kmeans_result['centroids']}")
|
|
284
|
+
print(f"K-means clusters: {kmeans_result['clusters']}")
|
|
299
285
|
|
|
300
286
|
# Linear regression
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
print(f"
|
|
306
|
-
print(f"
|
|
287
|
+
# Note: Linear regression expects X as 2D array and y as 1D array
|
|
288
|
+
X = [[1, 1], [1, 2], [2, 2], [2, 3]]
|
|
289
|
+
y = [6, 8, 9, 11]
|
|
290
|
+
regression_result = pyroid.ml.basic.linear_regression(X, y)
|
|
291
|
+
print(f"Linear regression coefficients: {regression_result['coefficients']}")
|
|
292
|
+
print(f"Linear regression intercept: {regression_result['intercept']}")
|
|
293
|
+
print(f"Linear regression R-squared: {regression_result['r_squared']}")
|
|
307
294
|
|
|
308
295
|
# Data normalization
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
print(f"Normalized (min-max): {normalized}")
|
|
296
|
+
normalized_data = pyroid.ml.basic.normalize(data, method="min-max")
|
|
297
|
+
print(f"Normalized data (min-max): {normalized_data}")
|
|
312
298
|
|
|
313
299
|
# Distance matrix
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
print(f"Distance matrix: {distances}")
|
|
300
|
+
distance_matrix = pyroid.ml.basic.distance_matrix(data, metric="euclidean")
|
|
301
|
+
print(f"Distance matrix shape: {len(distance_matrix)}x{len(distance_matrix[0])}")
|
|
317
302
|
```
|
|
318
303
|
|
|
319
304
|
## 📊 Performance Considerations
|
|
@@ -11,6 +11,20 @@ The benchmark suite provides:
|
|
|
11
11
|
- Comprehensive visualizations for marketing materials
|
|
12
12
|
- Real-world scenario benchmarks that simulate practical use cases
|
|
13
13
|
|
|
14
|
+
## Performance Benchmarks
|
|
15
|
+
|
|
16
|
+
Pyroid significantly outperforms pure Python implementations. Here are some benchmark results:
|
|
17
|
+
|
|
18
|
+
| Operation | Pure Python | NumPy | pyroid | Speedup vs Python | Speedup vs NumPy |
|
|
19
|
+
|-----------|-------------|-------|--------|-------------------|------------------|
|
|
20
|
+
| Sum 10M numbers | Timed out (10s) | 50.15ms | 45.32ms | >220x | 1.11x |
|
|
21
|
+
| Regex replace 1M chars | 250.45ms | N/A | 20.35ms | 12.31x | N/A |
|
|
22
|
+
| Parallel map 1M items | 450.78ms | N/A | 35.67ms | 12.64x | N/A |
|
|
23
|
+
| HTTP fetch 100 URLs | 5000.34ms | N/A | 500.12ms | 10.00x | N/A |
|
|
24
|
+
| Data Processing Pipeline | Timed out (30s) | N/A | 250.34ms | >120x | N/A |
|
|
25
|
+
|
|
26
|
+
> Note: These are example results. Run the benchmark suite in the `benchmarks` directory to generate actual results for your system.
|
|
27
|
+
|
|
14
28
|
## Quick Start
|
|
15
29
|
|
|
16
30
|
### Jupyter Notebook
|
|
@@ -60,13 +74,32 @@ For a quick demonstration of Pyroid's performance advantages:
|
|
|
60
74
|
python benchmarks/demo.py
|
|
61
75
|
```
|
|
62
76
|
|
|
77
|
+
## Benchmark Dashboard
|
|
78
|
+
|
|
79
|
+
The benchmark suite includes a comprehensive dashboard with visualizations that showcase Pyroid's performance advantages:
|
|
80
|
+
|
|
81
|
+
- Performance metrics summary
|
|
82
|
+
- Speedup comparison charts
|
|
83
|
+
- Implementation comparison charts (log and linear scales)
|
|
84
|
+
- Scaling analysis showing how performance scales with dataset size
|
|
85
|
+
- Real-world scenario benchmarks
|
|
86
|
+
|
|
87
|
+
To run the benchmarks and generate the dashboard:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
python -m benchmarks.run_benchmarks
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The dashboard will be available at `benchmarks/dashboard/dashboard.html`.
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
63
97
|
## Directory Structure
|
|
64
98
|
|
|
65
99
|
```
|
|
66
100
|
benchmarks/
|
|
67
101
|
├── benchmark_plan.md # Detailed implementation plan
|
|
68
102
|
├── README.md # This file
|
|
69
|
-
├── README_update.md # Template for updating the main README
|
|
70
103
|
├── pyroid_benchmarks.ipynb # Jupyter notebook for interactive benchmarks
|
|
71
104
|
├── run_benchmarks.py # Main entry point for command-line benchmarks
|
|
72
105
|
├── demo.py # Demo script for showcasing performance
|
|
@@ -107,7 +140,9 @@ benchmarks/
|
|
|
107
140
|
- Task concurrency vs. asyncio.gather
|
|
108
141
|
|
|
109
142
|
5. **Real-world Scenarios**
|
|
110
|
-
- Data Processing Pipeline
|
|
111
|
-
- Web Scraping and
|
|
112
|
-
- Text Processing
|
|
113
|
-
- Scientific Computing
|
|
143
|
+
- Data Processing Pipeline: ETL operations on large datasets
|
|
144
|
+
- Web Scraping: Concurrent URL fetching and text processing
|
|
145
|
+
- Text Processing: NLP preprocessing tasks
|
|
146
|
+
- Scientific Computing: Statistical analysis and mathematical transformations
|
|
147
|
+
|
|
148
|
+
These benchmarks simulate practical use cases that users can relate to, demonstrating how Pyroid can significantly accelerate your Python code in production environments.
|