fastpython-native 0.2.0__py3-none-any.whl → 0.2.2__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 +1 -1
- fastpython/api.py +3 -1
- fastpython/memory/__init__.py +11 -1
- fastpython/memory/arena.py +11 -1
- fastpython/server/__init__.py +14 -5
- fastpython/simd/__init__.py +13 -1
- fastpython/simd/fast_json.py +11 -1
- {fastpython_native-0.2.0.dist-info → fastpython_native-0.2.2.dist-info}/METADATA +2 -2
- {fastpython_native-0.2.0.dist-info → fastpython_native-0.2.2.dist-info}/RECORD +12 -12
- {fastpython_native-0.2.0.dist-info → fastpython_native-0.2.2.dist-info}/WHEEL +0 -0
- {fastpython_native-0.2.0.dist-info → fastpython_native-0.2.2.dist-info}/entry_points.txt +0 -0
- {fastpython_native-0.2.0.dist-info → fastpython_native-0.2.2.dist-info}/top_level.txt +0 -0
fastpython/__init__.py
CHANGED
fastpython/api.py
CHANGED
|
@@ -4,10 +4,12 @@ Provides decorators and pre-start compilation helpers to turn Python functions
|
|
|
4
4
|
into hardware-optimized machine code.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
7
9
|
import functools
|
|
8
10
|
import inspect
|
|
9
11
|
import time
|
|
10
|
-
from typing import Callable, Dict, Any, Optional
|
|
12
|
+
from typing import Callable, Dict, Any, Optional, Tuple
|
|
11
13
|
|
|
12
14
|
from .hardware.cpu import get_cpu_info
|
|
13
15
|
from .compiler.toolchain import CompilerToolchain
|
fastpython/memory/__init__.py
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
try:
|
|
2
|
+
from .aligned_mem import allocate, AlignedBuffer
|
|
3
|
+
except (ImportError, Exception):
|
|
4
|
+
def allocate(size, alignment=64):
|
|
5
|
+
return bytearray(size)
|
|
6
|
+
class AlignedBuffer:
|
|
7
|
+
def __init__(self, size, alignment=64):
|
|
8
|
+
self.buf = bytearray(size)
|
|
9
|
+
def __len__(self):
|
|
10
|
+
return len(self.buf)
|
|
11
|
+
|
|
2
12
|
from .arena import BumpArena
|
|
3
13
|
|
|
4
14
|
__all__ = ["allocate", "AlignedBuffer", "BumpArena"]
|
fastpython/memory/arena.py
CHANGED
|
@@ -4,7 +4,17 @@ Replaces heap malloc/free cycles with instantaneous O(1) pointer bumps.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from typing import Optional
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from .aligned_mem import allocate, AlignedBuffer
|
|
10
|
+
except (ImportError, Exception):
|
|
11
|
+
def allocate(size, alignment=64):
|
|
12
|
+
return bytearray(size)
|
|
13
|
+
class AlignedBuffer:
|
|
14
|
+
def __init__(self, size, alignment=64):
|
|
15
|
+
self.buf = bytearray(size)
|
|
16
|
+
def __len__(self):
|
|
17
|
+
return len(self.buf)
|
|
8
18
|
|
|
9
19
|
|
|
10
20
|
class BumpArena:
|
fastpython/server/__init__.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import time
|
|
2
2
|
from typing import Optional, Dict, Any
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from . import native_server
|
|
6
|
+
except (ImportError, Exception):
|
|
7
|
+
native_server = None
|
|
4
8
|
|
|
5
9
|
|
|
6
10
|
class FastWebServer:
|
|
@@ -16,16 +20,21 @@ class FastWebServer:
|
|
|
16
20
|
|
|
17
21
|
def start(self):
|
|
18
22
|
if not self.is_running:
|
|
19
|
-
native_server
|
|
20
|
-
|
|
23
|
+
if native_server is not None:
|
|
24
|
+
native_server.start(self.port, self.threads)
|
|
25
|
+
self.is_running = True
|
|
26
|
+
else:
|
|
27
|
+
raise RuntimeError("FastWebServer native server module is not built for this Python environment.")
|
|
21
28
|
|
|
22
29
|
def stop(self):
|
|
23
|
-
if self.is_running:
|
|
30
|
+
if self.is_running and native_server is not None:
|
|
24
31
|
native_server.stop()
|
|
25
32
|
self.is_running = False
|
|
26
33
|
|
|
27
34
|
def stats(self) -> Dict[str, Any]:
|
|
28
|
-
|
|
35
|
+
if native_server is not None:
|
|
36
|
+
return native_server.get_stats()
|
|
37
|
+
return {}
|
|
29
38
|
|
|
30
39
|
def __enter__(self):
|
|
31
40
|
self.start()
|
fastpython/simd/__init__.py
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
try:
|
|
2
|
+
from .fast_simd import find_char, find_crlf, parse_http_request, dumps
|
|
3
|
+
except (ImportError, Exception):
|
|
4
|
+
import json
|
|
5
|
+
def dumps(obj):
|
|
6
|
+
return json.dumps(obj)
|
|
7
|
+
def find_char(buf, char):
|
|
8
|
+
return buf.find(char)
|
|
9
|
+
def find_crlf(buf):
|
|
10
|
+
return buf.find(b"\r\n")
|
|
11
|
+
def parse_http_request(req):
|
|
12
|
+
return {}
|
|
13
|
+
|
|
2
14
|
from .fast_json import fast_scan_keys
|
|
3
15
|
|
|
4
16
|
__all__ = ["find_char", "find_crlf", "parse_http_request", "dumps", "fast_scan_keys"]
|
fastpython/simd/fast_json.py
CHANGED
|
@@ -4,7 +4,17 @@ Leverages AVX2 vector registers to parse JSON documents at multi-gigabyte/sec th
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from typing import Any, Dict, List, Union
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from .fast_simd import dumps as fast_dumps, find_char, find_crlf
|
|
10
|
+
except (ImportError, Exception):
|
|
11
|
+
import json
|
|
12
|
+
def fast_dumps(obj):
|
|
13
|
+
return json.dumps(obj)
|
|
14
|
+
def find_char(buf, char):
|
|
15
|
+
return buf.find(char)
|
|
16
|
+
def find_crlf(buf):
|
|
17
|
+
return buf.find(b"\r\n")
|
|
8
18
|
|
|
9
19
|
|
|
10
20
|
def fast_scan_keys(json_bytes: bytes) -> Dict[str, Union[int, float, str, bool, None]]:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastpython-native
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: AOT Hardware-Adaptive Native Machine Code Compiler for Python
|
|
5
|
-
Author:
|
|
5
|
+
Author: alex9347
|
|
6
6
|
Keywords: compiler,performance,aot,simd,avx2,jit,optimization
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: Operating System :: Microsoft :: Windows
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
fastpython/__init__.py,sha256=
|
|
1
|
+
fastpython/__init__.py,sha256=Ks1ntwjAKmKeSnizgIyeCy6dhh9iEivYXN_AoCpE_aw,583
|
|
2
2
|
fastpython/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
|
3
|
-
fastpython/api.py,sha256=
|
|
3
|
+
fastpython/api.py,sha256=Urm-aEzv_ohMmEHBbgpKpvsb3NPFf2k1-lvN8dWfz-U,6930
|
|
4
4
|
fastpython/auto.py,sha256=aHFcXX8gijt01sYlbZymyS4wSzXFZHLLeGvtB1u30OM,283
|
|
5
5
|
fastpython/cli.py,sha256=5ezV99gntwqJNOnNzaVSYLmVXhOCd0Aa7iRm-GCbmnQ,3184
|
|
6
6
|
fastpython/importer.py,sha256=pq0ghgpK2qFdIIFVv97klm6oeXZcuKgZFZl9JRSpgVg,7275
|
|
@@ -14,16 +14,16 @@ fastpython/compiler/cache.py,sha256=l-7CMjWzqaxfKEKdYhgzVBmWjoRVkf0cnr_iP-zNmS0,
|
|
|
14
14
|
fastpython/compiler/toolchain.py,sha256=LDVH4LyoRW3r5ooTaYntGUJRz2pPbbK3treOk3CAxFM,5037
|
|
15
15
|
fastpython/hardware/__init__.py,sha256=moeI5cy5Rb_owglRaUktFwHLF-8fiLQOE7sISpDsA6I,86
|
|
16
16
|
fastpython/hardware/cpu.py,sha256=g68IdKvmZeZhl59q23rE2YcG5AsXxmrMt8fsSWTTDco,7383
|
|
17
|
-
fastpython/memory/__init__.py,sha256=
|
|
17
|
+
fastpython/memory/__init__.py,sha256=tVzju63avhsALJU6gpZYBJJOIIttVEd1zBRAlkPnUic,416
|
|
18
18
|
fastpython/memory/aligned_mem.c,sha256=sYEfnOmuwpBeXca-mNX3EwlVgvAL5S6JzZWLh712Mq8,3318
|
|
19
|
-
fastpython/memory/arena.py,sha256=
|
|
20
|
-
fastpython/server/__init__.py,sha256=
|
|
19
|
+
fastpython/memory/arena.py,sha256=1qRA5AuTKshM-q9XRwkk6MPFKV_0klc_3ChKPlLSrgg,1919
|
|
20
|
+
fastpython/server/__init__.py,sha256=TYX33EDgngQB-E5BBVFRE_u0vn9tGJOcqcuwDBJIzk8,1320
|
|
21
21
|
fastpython/server/native_server.c,sha256=LupO6CkSy1f01297ILWzf_eN7lOWwtiY1ACn1KtUEHw,7195
|
|
22
|
-
fastpython/simd/__init__.py,sha256=
|
|
23
|
-
fastpython/simd/fast_json.py,sha256=
|
|
22
|
+
fastpython/simd/__init__.py,sha256=ID-MWvL0UYooW-DnZLdPNv6IzXxNlfNCxWHVbCD-ln4,474
|
|
23
|
+
fastpython/simd/fast_json.py,sha256=lr7Y9XMJDF7_4R5nBuiJ641_yfBRXwxHt-KDchhrjPI,2423
|
|
24
24
|
fastpython/simd/fast_simd.c,sha256=zltkJBr-Jx1kWFWfmLBuzhkizYOhYGRxpVtACnV5csc,9446
|
|
25
|
-
fastpython_native-0.2.
|
|
26
|
-
fastpython_native-0.2.
|
|
27
|
-
fastpython_native-0.2.
|
|
28
|
-
fastpython_native-0.2.
|
|
29
|
-
fastpython_native-0.2.
|
|
25
|
+
fastpython_native-0.2.2.dist-info/METADATA,sha256=doFvoo3wPrvMxkTyGafqt3yDaNQUByNEAb2LjNb-IAY,10729
|
|
26
|
+
fastpython_native-0.2.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
27
|
+
fastpython_native-0.2.2.dist-info/entry_points.txt,sha256=IGbP7VbTQmM-57joccriVqB2ieX5uU4u0K5k49HvhE0,51
|
|
28
|
+
fastpython_native-0.2.2.dist-info/top_level.txt,sha256=XjyQFL6KqwXjTwH8faHiYGaSiNuJMpZ2ChIn64covz4,11
|
|
29
|
+
fastpython_native-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|