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 CHANGED
@@ -22,4 +22,4 @@ __all__ = [
22
22
  "simd",
23
23
  "memory",
24
24
  ]
25
- __version__ = "0.2.0"
25
+ __version__ = "0.2.2"
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
@@ -1,4 +1,14 @@
1
- from .aligned_mem import allocate, AlignedBuffer
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"]
@@ -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
- from .aligned_mem import allocate, AlignedBuffer
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:
@@ -1,6 +1,10 @@
1
1
  import time
2
2
  from typing import Optional, Dict, Any
3
- from . import native_server
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.start(self.port, self.threads)
20
- self.is_running = True
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
- return native_server.get_stats()
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()
@@ -1,4 +1,16 @@
1
- from .fast_simd import find_char, find_crlf, parse_http_request, dumps
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"]
@@ -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
- from .fast_simd import dumps as fast_dumps, find_char, find_crlf
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.0
3
+ Version: 0.2.2
4
4
  Summary: AOT Hardware-Adaptive Native Machine Code Compiler for Python
5
- Author: FastPython Team
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=hn1Vl9J1xUfjzP3fFZXW16ILnfHRqmcebtTif-Ie-NA,583
1
+ fastpython/__init__.py,sha256=Ks1ntwjAKmKeSnizgIyeCy6dhh9iEivYXN_AoCpE_aw,583
2
2
  fastpython/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
3
- fastpython/api.py,sha256=ZXSTpYrUqnrCEnc1nx8LqbF9g6X-ePUNZ2RPCzrQCu8,6887
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=aGD04hLevPOtCVWt3BOEg5ZycekyiXuiXI1dcSJ6bR4,132
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=34ZwW-d6FjA7940ZIOxZz99iJupJBxn_KjCFsFYintk,1635
20
- fastpython/server/__init__.py,sha256=uLFW9kKwxc0mlBalIDzDJc-zCTCgVVvIueofR8knrD0,979
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=txxoUEhe5Fq67Vh1pdXFYBWXk4Q3l1MmLa76pRltKBc,196
23
- fastpython/simd/fast_json.py,sha256=BV63OYI0sY7q_MUYhuol-s4RHpCvZMFz8lZsyBD6uCU,2191
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.0.dist-info/METADATA,sha256=uHTsQWjJJisl2HgihnvPsukSa15TfMTXVZzpZPeZAYE,10736
26
- fastpython_native-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
27
- fastpython_native-0.2.0.dist-info/entry_points.txt,sha256=IGbP7VbTQmM-57joccriVqB2ieX5uU4u0K5k49HvhE0,51
28
- fastpython_native-0.2.0.dist-info/top_level.txt,sha256=XjyQFL6KqwXjTwH8faHiYGaSiNuJMpZ2ChIn64covz4,11
29
- fastpython_native-0.2.0.dist-info/RECORD,,
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,,