File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 7
7
8
8
9
9
def native (func : __T ) -> __T :
10
+ """
11
+ A decorator that attempts to optimize a Python function by
12
+ translating it into a native implementation.
13
+
14
+ **Note**: This decorator is an experimental prototype and has been
15
+ abandoned. It is incomplete, lacks proper maintenance, and may not
16
+ work as expected in all cases. Use it at your own risk.
17
+
18
+ Parameters:
19
+ func (__T): The Python function to be optimized.
20
+
21
+ Returns:
22
+ __T: The (potentially) optimized function.
23
+
24
+ Warning:
25
+ This decorator has been deprecated and is no longer maintained.
26
+ It is provided for demonstration purposes only and should not
27
+ be used in production code.
28
+
29
+ Example:
30
+ @native
31
+ def add(a, b):
32
+ return a + b
33
+ """
10
34
return _native (func )
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def native(n):
28
28
return x
29
29
30
30
31
- def setupAsm ():
31
+ def setupRealNative ():
32
32
global asmFunc
33
33
34
34
asmCode = f"""
@@ -56,13 +56,25 @@ def realNative():
56
56
return unsafe .callLongLong (asmFunc )
57
57
58
58
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
59
71
def main ():
60
72
global SIZE
61
73
print (f"---Python & Native & Real-Native for Benchmark---" )
62
74
print (f"Batch size: { SIZE } " )
63
75
print (f"Repeat: { REPEAT } \n " )
64
76
65
- setupAsm ()
77
+ setupRealNative ()
66
78
assert python (SIZE ) == native (SIZE ) == realNative ()
67
79
assert native .__doc__ == "<native method>"
68
80
You can’t perform that action at this time.
0 commit comments