polyglot-bridge 0.1.0__cp310-cp310-macosx_10_12_x86_64.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,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type stubs for polyglot_bridge
|
|
3
|
+
|
|
4
|
+
The Polyglot Bridge: High-performance Rust library with Python bindings
|
|
5
|
+
Accelerate your ML data pipelines with Rust-powered computational functions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import List
|
|
9
|
+
|
|
10
|
+
def sum_of_squares(numbers: List[float]) -> float:
|
|
11
|
+
"""
|
|
12
|
+
Compute the sum of squares for a list of numbers.
|
|
13
|
+
|
|
14
|
+
This function provides significant performance improvements over pure Python
|
|
15
|
+
implementations, especially for large datasets.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
numbers: A list of numeric values
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
The sum of squares of all numbers
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
ValueError: If the input list is empty
|
|
25
|
+
RuntimeError: If computation results in overflow
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
>>> import polyglot_bridge
|
|
29
|
+
>>> polyglot_bridge.sum_of_squares([1.0, 2.0, 3.0])
|
|
30
|
+
14.0
|
|
31
|
+
|
|
32
|
+
>>> # Performance: ~3x faster than pure Python
|
|
33
|
+
>>> data = list(range(10000))
|
|
34
|
+
>>> result = polyglot_bridge.sum_of_squares(data)
|
|
35
|
+
"""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
def matrix_multiply(a: List[List[float]], b: List[List[float]]) -> List[List[float]]:
|
|
39
|
+
"""
|
|
40
|
+
Multiply two matrices using optimized Rust implementation.
|
|
41
|
+
|
|
42
|
+
This function delivers exceptional performance gains (up to 95x faster)
|
|
43
|
+
compared to pure Python implementations, making it ideal for ML pipelines
|
|
44
|
+
that involve heavy matrix operations.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
a: First matrix (m × n)
|
|
48
|
+
b: Second matrix (n × p)
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Result matrix (m × p)
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
ValueError: If matrices are empty or dimensions don't match
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
>>> import polyglot_bridge
|
|
58
|
+
>>> a = [[1.0, 2.0], [3.0, 4.0]]
|
|
59
|
+
>>> b = [[5.0, 6.0], [7.0, 8.0]]
|
|
60
|
+
>>> result = polyglot_bridge.matrix_multiply(a, b)
|
|
61
|
+
>>> # Result: [[19.0, 22.0], [43.0, 50.0]]
|
|
62
|
+
|
|
63
|
+
>>> # Performance: Up to 95x faster for 50×50 matrices
|
|
64
|
+
>>> # Perfect for feature transformation in ML pipelines
|
|
65
|
+
"""
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
def parallel_transform(data: List[float], factor: float) -> List[float]:
|
|
69
|
+
"""
|
|
70
|
+
Transform data in parallel by multiplying each element by a factor.
|
|
71
|
+
|
|
72
|
+
This function leverages Rayon for automatic parallelization across CPU cores,
|
|
73
|
+
providing optimal performance for large datasets without manual thread management.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
data: Input data to transform
|
|
77
|
+
factor: Multiplication factor
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Transformed data with each element multiplied by factor
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ValueError: If the input list is empty
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
>>> import polyglot_bridge
|
|
87
|
+
>>> data = [1.0, 2.0, 3.0, 4.0, 5.0]
|
|
88
|
+
>>> result = polyglot_bridge.parallel_transform(data, 2.0)
|
|
89
|
+
>>> # Result: [2.0, 4.0, 6.0, 8.0, 10.0]
|
|
90
|
+
|
|
91
|
+
>>> # Automatic parallelization - no threading code needed
|
|
92
|
+
>>> large_data = list(range(100000))
|
|
93
|
+
>>> result = polyglot_bridge.parallel_transform(large_data, 1.5)
|
|
94
|
+
"""
|
|
95
|
+
...
|
|
96
|
+
|
|
97
|
+
__all__ = ['sum_of_squares', 'matrix_multiply', 'parallel_transform']
|
|
Binary file
|
polyglot_bridge/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polyglot-bridge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Summary: High-performance Rust library with Python bindings
|
|
11
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
polyglot_bridge/__init__.py,sha256=0BuM9rDF-lZYAGsBjM6ZhIOQaKYmlzTGX9JMDvU20B0,143
|
|
2
|
+
polyglot_bridge/__init__.pyi,sha256=b9BcV8K5wNvKZ-7qUXLvS-BJ8m_rHsUajbbCK4XRCpY,3040
|
|
3
|
+
polyglot_bridge/polyglot_bridge.cpython-310-darwin.so,sha256=dI8EWg7dlUvvfVWD5YiE6wxU0Y8iHk878IyU94_h_zY,609588
|
|
4
|
+
polyglot_bridge/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
polyglot_bridge-0.1.0.dist-info/METADATA,sha256=DBPCqVhF2vs8fLKclRw-FyCv73P3r0PhiBfVwlGE-Gw,436
|
|
6
|
+
polyglot_bridge-0.1.0.dist-info/WHEEL,sha256=SH2iwf33rrTAQQTAxViKnknF7OtYc7LWwc1oMZ0yCgI,107
|
|
7
|
+
polyglot_bridge-0.1.0.dist-info/RECORD,,
|