fastpython-native 0.1.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.
- fastpython/__init__.py +19 -0
- fastpython/__main__.py +4 -0
- fastpython/api.py +185 -0
- fastpython/auto.py +10 -0
- fastpython/cli.py +84 -0
- fastpython/codegen/__init__.py +3 -0
- fastpython/codegen/transpiler.py +545 -0
- fastpython/compiler/__init__.py +4 -0
- fastpython/compiler/cache.py +57 -0
- fastpython/compiler/toolchain.py +147 -0
- fastpython/hardware/__init__.py +3 -0
- fastpython/hardware/cpu.py +209 -0
- fastpython/importer.py +181 -0
- fastpython/memory/__init__.py +3 -0
- fastpython/server/__init__.py +38 -0
- fastpython/simd/__init__.py +10 -0
- fastpython_native-0.1.0.dist-info/METADATA +108 -0
- fastpython_native-0.1.0.dist-info/RECORD +21 -0
- fastpython_native-0.1.0.dist-info/WHEEL +5 -0
- fastpython_native-0.1.0.dist-info/entry_points.txt +2 -0
- fastpython_native-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastpython-native
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AOT Hardware-Adaptive Native Machine Code Compiler for Python
|
|
5
|
+
Author: FastPython Team
|
|
6
|
+
Keywords: compiler,performance,aot,simd,avx2,jit,optimization
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# FastPython ⚡
|
|
15
|
+
|
|
16
|
+
> **AOT Hardware-Adaptive Native Machine Code Compiler for Python**
|
|
17
|
+
|
|
18
|
+
FastPython erkennt beim Start automatisch die Architektur und Fähigkeiten deiner Host-CPU (AVX2, AVX-512, FMA3, BMI2, Cache & Kerne), analysiert deine Python-Funktionen, übersetzt rechenintensive Schleifen und Algorithmen in optimierten C99/C++ Code und kompiliert diesen **vor dem Start** in hardwarenahen Maschinencode.
|
|
19
|
+
|
|
20
|
+
Beim wiederholten Starten sorgt ein intelligentes SHA-256 Caching dafür, dass keine Kompilierungszeit anfällt und das Modul in **unter 1 Millisekunde** direkt aus dem Cache geladen wird.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 Benchmark-Ergebnisse (auf AMD Ryzen 7 5700X, 16 Threads, AVX2, FMA3)
|
|
25
|
+
|
|
26
|
+
| Bereich / Algorithmus | Standard CPython | FastPython (Host AOT) | Beschleunigung |
|
|
27
|
+
| :--- | :---: | :---: | :---: |
|
|
28
|
+
| **Fraktale: Mandelbrot Multi-Core** (250x250, 16 Threads) | 662,7 ms | **1,45 ms** | **⚡ 458,2x schneller** |
|
|
29
|
+
| **Stochastik: Monte Carlo Pi** (3 Mio. Samples) | 4.234,6 ms | **13,7 ms** | **⚡ 308,6x schneller** |
|
|
30
|
+
| **Lineare Algebra: Vector Dot** (1.000.000 Floats SIMD) | 121,5 ms | **0,73 ms** | **⚡ 167,4x schneller** |
|
|
31
|
+
| **Zahlentheorie: Collatz-Suche** (50.000 Zahlen) | 698,3 ms | **7,2 ms** | **⚡ 96,8x schneller** |
|
|
32
|
+
| **Fraktale: Mandelbrot Single-Core** (250x250, AVX2) | 651,4 ms | **8,58 ms** | **⚡ 75,9x schneller** |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🛠️ Verwendung
|
|
37
|
+
|
|
38
|
+
### 1. Zero-Touch Projekt-Beschleunigung (Empfohlen)
|
|
39
|
+
|
|
40
|
+
Füge einfach in deiner `main.py` als erste Zeile hinzu:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import fastpython.auto # Aktiviert automatische Hardware-AOT-Kompilierung für das Projekt
|
|
44
|
+
|
|
45
|
+
# Ab hier: Importiere deine ganz normalen Projektdateien (ohne Decorator oder Änderungen!)
|
|
46
|
+
import simulation
|
|
47
|
+
import math_utils
|
|
48
|
+
|
|
49
|
+
# Alle Funktionen in diesen Dateien laufen jetzt im nativen Maschinencode!
|
|
50
|
+
simulation.run()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Führe dein Skript wie gewohnt mit Python aus:
|
|
54
|
+
```bash
|
|
55
|
+
python main.py
|
|
56
|
+
```
|
|
57
|
+
FastPython fängt alle Projekt-Imports ab, identifiziert rechenintensive Funktionen in allen Projektdateien, kompiliert sie vor der Ausführung in AVX2-Maschinencode und sichert sie im Cache. Bei jedem weiteren Start startet das Programm ohne Verzögerung sofort im nativen Modus.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 2. Als gezielter Decorator für einzelne Funktionen
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from fastpython import compile_native
|
|
65
|
+
|
|
66
|
+
@compile_native(fastmath=True, parallel=True)
|
|
67
|
+
def calculate_pi(n: int) -> float:
|
|
68
|
+
acc = 0.0
|
|
69
|
+
sign = 1.0
|
|
70
|
+
for i in range(n):
|
|
71
|
+
denom = 2.0 * float(i) + 1.0
|
|
72
|
+
acc += sign / denom
|
|
73
|
+
sign = -sign
|
|
74
|
+
return 4.0 * acc
|
|
75
|
+
|
|
76
|
+
print(calculate_pi(20_000_000)) # 20 Millionen Iterationen in ~25ms!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 3. Über das Command Line Interface (CLI)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Host-Hardware analysieren
|
|
85
|
+
python -m fastpython info
|
|
86
|
+
|
|
87
|
+
# Benchmark-Suite ausführen
|
|
88
|
+
python -m fastpython benchmark
|
|
89
|
+
|
|
90
|
+
# Eigenes Skript mit FastPython starten
|
|
91
|
+
python -m fastpython run dein_skript.py
|
|
92
|
+
|
|
93
|
+
# Cache leeren
|
|
94
|
+
python -m fastpython clear-cache
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ⚙️ Wie es unter der Haube funktioniert
|
|
100
|
+
|
|
101
|
+
1. **Hardware-Profiling (`fastpython.hardware`)**:
|
|
102
|
+
Liest über Low-Level CPUID und System-APIs ab, welche Befehlssätze dein Prozessor unterstützt (z. B. AVX2, FMA3, NEON).
|
|
103
|
+
2. **AST-Transpiler (`fastpython.codegen`)**:
|
|
104
|
+
Untersucht den Python Abstract Syntax Tree (AST), extrahiert numerische Datentypen (int64_t, double) und entfernt das Python-Objekt-Boxing in inneren Schleifen.
|
|
105
|
+
3. **Host-Compiler (`fastpython.compiler`)**:
|
|
106
|
+
Generiert die native C-Erweiterung und ruft den lokalen Compiler (MSVC BuildTools / Clang / GCC) mit maximalen Hardware-Flags (`/arch:AVX2 /fp:fast /O2 /Oi /Ot`) auf.
|
|
107
|
+
4. **Caching-Layer**:
|
|
108
|
+
Hasht Quellcode + CPU-Fingerprint + Compiler-Flags. Bei erneutem Start wird der kompilierte Maschinencode (`.pyd` / `.so`) sofort eingebunden.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
fastpython/__init__.py,sha256=gFcil8B65koaFWRzl2mogEyUR8GLkU05n9rPPj58aKg,442
|
|
2
|
+
fastpython/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
|
3
|
+
fastpython/api.py,sha256=zSls5141Y2JYCbLoy5xWhQnzWCPUu8o0oqbfmEDrGPg,6355
|
|
4
|
+
fastpython/auto.py,sha256=aHFcXX8gijt01sYlbZymyS4wSzXFZHLLeGvtB1u30OM,283
|
|
5
|
+
fastpython/cli.py,sha256=5ezV99gntwqJNOnNzaVSYLmVXhOCd0Aa7iRm-GCbmnQ,3184
|
|
6
|
+
fastpython/importer.py,sha256=feqc-P5lpwpK4YCHgkzjUToFIHg0MK8TpHaPV4-9qvg,6712
|
|
7
|
+
fastpython/codegen/__init__.py,sha256=fqqGp_3A9TwzdnC8vWKyfe3zwN6YLPSt_ZnG_DmtzPA,173
|
|
8
|
+
fastpython/codegen/transpiler.py,sha256=vqk3Ge3Y43WXJfpGHBA13H1oFXb_9OKjiOR8TUmbz08,18759
|
|
9
|
+
fastpython/compiler/__init__.py,sha256=oQfnYP3KTfl6Nyr8rBWmTwUGCPqvjIVgo-qzbsiI_r0,158
|
|
10
|
+
fastpython/compiler/cache.py,sha256=l-7CMjWzqaxfKEKdYhgzVBmWjoRVkf0cnr_iP-zNmS0,2269
|
|
11
|
+
fastpython/compiler/toolchain.py,sha256=PVdkfyFxqYUYoLojuS_VYXZ_m-adJJCskscgEk7J1ZE,4832
|
|
12
|
+
fastpython/hardware/__init__.py,sha256=moeI5cy5Rb_owglRaUktFwHLF-8fiLQOE7sISpDsA6I,86
|
|
13
|
+
fastpython/hardware/cpu.py,sha256=g68IdKvmZeZhl59q23rE2YcG5AsXxmrMt8fsSWTTDco,7383
|
|
14
|
+
fastpython/memory/__init__.py,sha256=GFlJr80kPS_6UyR-6b7L_hOyf1kFxGSM2o3iqJH2WkA,90
|
|
15
|
+
fastpython/server/__init__.py,sha256=uLFW9kKwxc0mlBalIDzDJc-zCTCgVVvIueofR8knrD0,979
|
|
16
|
+
fastpython/simd/__init__.py,sha256=LFRppwAExJfEgeczPqeiiHV-fovjd48vGH8uKkRhZIY,305
|
|
17
|
+
fastpython_native-0.1.0.dist-info/METADATA,sha256=llH99CCx0iK_5NxhVSicpyDoN-w5LsUhZkDx2f0iqCY,4326
|
|
18
|
+
fastpython_native-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
19
|
+
fastpython_native-0.1.0.dist-info/entry_points.txt,sha256=IGbP7VbTQmM-57joccriVqB2ieX5uU4u0K5k49HvhE0,51
|
|
20
|
+
fastpython_native-0.1.0.dist-info/top_level.txt,sha256=XjyQFL6KqwXjTwH8faHiYGaSiNuJMpZ2ChIn64covz4,11
|
|
21
|
+
fastpython_native-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fastpython
|