l0n0lc 0.8.0__tar.gz → 0.8.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: l0n0lc
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -8,13 +8,54 @@ Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Dynamic: license-file
10
10
 
11
+
11
12
  # 将python函数翻译为c++函数并运行
12
- ## 安装
13
+ ## 1. 安装
13
14
  ```
14
15
  pip install l0n0lc
15
16
  ```
17
+ ## 2. 运行hello_world.py
18
+ ```
19
+ uv run tests/hello_world.py
20
+ # 输入: b'1\n2\n100\n101\n'
21
+ ```
22
+ ```bash
23
+ 输出map:
24
+ c 3
25
+ a 1
26
+ b 2
27
+ 输出list:
28
+ 0 134
29
+ 1 3
30
+ 2 2
31
+ Hello World 13 3
32
+ test_other_fn 10
33
+ test编译的函数 39
34
+ 请输入>>>输入的 1 小于等于100
35
+ 请输入>>>输入的 2 小于等于100
36
+ 请输入>>>输入的 100 小于等于100
37
+ 请输入>>>结果: 241
38
+
39
+ ```
40
+
41
+ ## 3. 查看输出文件
42
+ ```bash
43
+ ls -al ./l0n0lcoutput
44
+ total 96
45
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
46
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
47
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
48
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
49
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
50
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
51
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
52
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
53
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
54
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
55
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
16
56
 
17
- ## hello_world.py
57
+ ```
58
+ ## 4. hello_world.py
18
59
  ```python
19
60
  import l0n0lc as lc
20
61
  import math
@@ -34,6 +75,15 @@ def cpp_cout(*args):
34
75
  return code
35
76
 
36
77
 
78
+ def py_cin(v):
79
+ pass
80
+
81
+
82
+ @lc.映射函数(py_cin, ['<iostream>'])
83
+ def cpp_cin(v):
84
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
85
+
86
+
37
87
  @lc.直接调用函数
38
88
  def test_直接调用():
39
89
  return 123
@@ -43,7 +93,7 @@ def test_other_fn(a: int, b: int) -> int:
43
93
  return a - b
44
94
 
45
95
 
46
- @lc.jit(每次运行都重新编译=True)
96
+ @lc.jit()
47
97
  def test编译的函数(a: int, b: int) -> int:
48
98
  return a * b
49
99
 
@@ -70,60 +120,22 @@ def test_add(a: int, b: int) -> int:
70
120
  print('Hello World', a, b)
71
121
  print('test_other_fn', test_other_fn(a, b))
72
122
  print('test编译的函数', test编译的函数(a, b))
73
- return a + b + 1 + test_直接调用()
123
+ v = 0
124
+ while (1):
125
+ py_cin(v)
126
+ if v > 100:
127
+ break
128
+ else:
129
+ print('输入的', v, '小于等于100')
130
+ return a + b + 1 + test_直接调用() + v
74
131
 
75
132
 
76
133
  print('结果:', test_add(1, 3))
77
- ```
78
- ## 执行hello_world.py
79
- ```bash
80
- $ python hello_world.py
81
- 输出map:
82
- c 3
83
- a 1
84
- b 2
85
- 输出list:
86
- 0 134
87
- 1 3
88
- 2 2
89
- Hello World 13 3
90
- test_other_fn 10
91
- test编译的函数 39
92
- 结果: 140
93
- ```
94
- ## 查看生成的c++代码文件
95
- ```bash
96
- $ ls -al l0n0lcoutput/
97
- total 96
98
- drwxr-xr-x 2 root root 4096 Sep 12 00:25 .
99
- drwxrwxrwx 11 1000 1000 4096 Sep 11 23:45 ..
100
- -rw-r--r-- 1 root root 994 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.cpp
101
- -rw-r--r-- 1 root root 246 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.h
102
- -rwxr-xr-x 1 root root 29744 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.so
103
- -rw-r--r-- 1 root root 121 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.cpp
104
- -rw-r--r-- 1 root root 93 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.h
105
- -rwxr-xr-x 1 root root 15616 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.so
106
- -rw-r--r-- 1 root root 185 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.cpp
107
- -rw-r--r-- 1 root root 151 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.h
108
- -rwxr-xr-x 1 root root 15656 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.so
109
- ```
110
-
111
- ## test_add_@6ddf6c9d797f5d1b.h
112
134
 
113
- ```c++
114
- #include "test_other_fn_@75fdd928ab58a8e3.h"
115
- #include "test编译的函数_@5f8bb0506cab8a49.h"
116
- #include <cmath>
117
- #include <cstdint>
118
- #include <iostream>
119
- #include <string>
120
- #include <unordered_map>
121
- extern "C" int64_t test_add (int64_t a, int64_t b);
122
135
  ```
123
-
124
- ## test_add_@6ddf6c9d797f5d1b.cpp
136
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
125
137
  ```c++
126
- #include "test_add_@6ddf6c9d797f5d1b.h"
138
+ #include "test_add_@3ecbfe0013e83ebc.h"
127
139
  extern "C" int64_t test_add (int64_t a, int64_t b)
128
140
  {
129
141
  if ((a > 1))
@@ -161,40 +173,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
161
173
  std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
162
174
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
163
175
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
164
- return a + b + 1 + 123;
176
+ auto v = 0;
177
+ while (1)
178
+ {
179
+ std::cout << u8"请输入>>>"; std::cin >> v;
180
+ if ((v > 100))
181
+ {
182
+ break;
183
+ }
184
+
185
+ {
186
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
187
+ }
188
+
189
+ }
190
+
191
+ return a + b + 1 + 123 + v;
165
192
  }
166
193
 
167
194
  ```
168
-
169
- ## test_other_fn_@75fdd928ab58a8e3.h
195
+ ## 6. test_add_@3ecbfe0013e83ebc.h
170
196
  ```c++
197
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
198
+ #include "test编译的函数_@3bf4501e0408a243.h"
199
+ #include <cmath>
171
200
  #include <cstdint>
201
+ #include <iostream>
172
202
  #include <string>
173
- extern "C" int64_t test_other_fn (int64_t a, int64_t b);
203
+ #include <unordered_map>
204
+ extern "C" int64_t test_add (int64_t a, int64_t b);
174
205
  ```
175
-
176
- ## test_other_fn_@75fdd928ab58a8e3.cpp
206
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
177
207
  ```c++
178
208
  #include "test_other_fn_@75fdd928ab58a8e3.h"
179
209
  extern "C" int64_t test_other_fn (int64_t a, int64_t b)
180
210
  {
181
211
  return a - b;
182
212
  }
183
- ```
184
213
 
185
-
186
- ## test编译的函数_@5f8bb0506cab8a49.h
214
+ ```
215
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
187
216
  ```c++
188
217
  #include <cstdint>
189
218
  #include <string>
190
- extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
219
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
191
220
  ```
192
-
193
- ## test编译的函数_@5f8bb0506cab8a49.cpp
221
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
194
222
  ```c++
195
- #include "test编译的函数_@5f8bb0506cab8a49.h"
223
+ #include "test编译的函数_@3bf4501e0408a243.h"
196
224
  extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
197
225
  {
198
226
  return a * b;
199
227
  }
228
+
229
+ ```
230
+ ## 10. test编译的函数_@3bf4501e0408a243.h
231
+ ```c++
232
+ #include <cstdint>
233
+ #include <string>
234
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
200
235
  ```
@@ -1,10 +1,51 @@
1
+
1
2
  # 将python函数翻译为c++函数并运行
2
- ## 安装
3
+ ## 1. 安装
3
4
  ```
4
5
  pip install l0n0lc
5
6
  ```
7
+ ## 2. 运行hello_world.py
8
+ ```
9
+ uv run tests/hello_world.py
10
+ # 输入: b'1\n2\n100\n101\n'
11
+ ```
12
+ ```bash
13
+ 输出map:
14
+ c 3
15
+ a 1
16
+ b 2
17
+ 输出list:
18
+ 0 134
19
+ 1 3
20
+ 2 2
21
+ Hello World 13 3
22
+ test_other_fn 10
23
+ test编译的函数 39
24
+ 请输入>>>输入的 1 小于等于100
25
+ 请输入>>>输入的 2 小于等于100
26
+ 请输入>>>输入的 100 小于等于100
27
+ 请输入>>>结果: 241
28
+
29
+ ```
30
+
31
+ ## 3. 查看输出文件
32
+ ```bash
33
+ ls -al ./l0n0lcoutput
34
+ total 96
35
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
36
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
37
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
38
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
39
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
40
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
41
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
42
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
43
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
44
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
45
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
6
46
 
7
- ## hello_world.py
47
+ ```
48
+ ## 4. hello_world.py
8
49
  ```python
9
50
  import l0n0lc as lc
10
51
  import math
@@ -24,6 +65,15 @@ def cpp_cout(*args):
24
65
  return code
25
66
 
26
67
 
68
+ def py_cin(v):
69
+ pass
70
+
71
+
72
+ @lc.映射函数(py_cin, ['<iostream>'])
73
+ def cpp_cin(v):
74
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
75
+
76
+
27
77
  @lc.直接调用函数
28
78
  def test_直接调用():
29
79
  return 123
@@ -33,7 +83,7 @@ def test_other_fn(a: int, b: int) -> int:
33
83
  return a - b
34
84
 
35
85
 
36
- @lc.jit(每次运行都重新编译=True)
86
+ @lc.jit()
37
87
  def test编译的函数(a: int, b: int) -> int:
38
88
  return a * b
39
89
 
@@ -60,60 +110,22 @@ def test_add(a: int, b: int) -> int:
60
110
  print('Hello World', a, b)
61
111
  print('test_other_fn', test_other_fn(a, b))
62
112
  print('test编译的函数', test编译的函数(a, b))
63
- return a + b + 1 + test_直接调用()
113
+ v = 0
114
+ while (1):
115
+ py_cin(v)
116
+ if v > 100:
117
+ break
118
+ else:
119
+ print('输入的', v, '小于等于100')
120
+ return a + b + 1 + test_直接调用() + v
64
121
 
65
122
 
66
123
  print('结果:', test_add(1, 3))
67
- ```
68
- ## 执行hello_world.py
69
- ```bash
70
- $ python hello_world.py
71
- 输出map:
72
- c 3
73
- a 1
74
- b 2
75
- 输出list:
76
- 0 134
77
- 1 3
78
- 2 2
79
- Hello World 13 3
80
- test_other_fn 10
81
- test编译的函数 39
82
- 结果: 140
83
- ```
84
- ## 查看生成的c++代码文件
85
- ```bash
86
- $ ls -al l0n0lcoutput/
87
- total 96
88
- drwxr-xr-x 2 root root 4096 Sep 12 00:25 .
89
- drwxrwxrwx 11 1000 1000 4096 Sep 11 23:45 ..
90
- -rw-r--r-- 1 root root 994 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.cpp
91
- -rw-r--r-- 1 root root 246 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.h
92
- -rwxr-xr-x 1 root root 29744 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.so
93
- -rw-r--r-- 1 root root 121 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.cpp
94
- -rw-r--r-- 1 root root 93 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.h
95
- -rwxr-xr-x 1 root root 15616 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.so
96
- -rw-r--r-- 1 root root 185 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.cpp
97
- -rw-r--r-- 1 root root 151 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.h
98
- -rwxr-xr-x 1 root root 15656 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.so
99
- ```
100
124
 
101
- ## test_add_@6ddf6c9d797f5d1b.h
102
-
103
- ```c++
104
- #include "test_other_fn_@75fdd928ab58a8e3.h"
105
- #include "test编译的函数_@5f8bb0506cab8a49.h"
106
- #include <cmath>
107
- #include <cstdint>
108
- #include <iostream>
109
- #include <string>
110
- #include <unordered_map>
111
- extern "C" int64_t test_add (int64_t a, int64_t b);
112
125
  ```
113
-
114
- ## test_add_@6ddf6c9d797f5d1b.cpp
126
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
115
127
  ```c++
116
- #include "test_add_@6ddf6c9d797f5d1b.h"
128
+ #include "test_add_@3ecbfe0013e83ebc.h"
117
129
  extern "C" int64_t test_add (int64_t a, int64_t b)
118
130
  {
119
131
  if ((a > 1))
@@ -151,40 +163,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
151
163
  std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
152
164
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
153
165
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
154
- return a + b + 1 + 123;
166
+ auto v = 0;
167
+ while (1)
168
+ {
169
+ std::cout << u8"请输入>>>"; std::cin >> v;
170
+ if ((v > 100))
171
+ {
172
+ break;
173
+ }
174
+
175
+ {
176
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
177
+ }
178
+
179
+ }
180
+
181
+ return a + b + 1 + 123 + v;
155
182
  }
156
183
 
157
184
  ```
158
-
159
- ## test_other_fn_@75fdd928ab58a8e3.h
185
+ ## 6. test_add_@3ecbfe0013e83ebc.h
160
186
  ```c++
187
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
188
+ #include "test编译的函数_@3bf4501e0408a243.h"
189
+ #include <cmath>
161
190
  #include <cstdint>
191
+ #include <iostream>
162
192
  #include <string>
163
- extern "C" int64_t test_other_fn (int64_t a, int64_t b);
193
+ #include <unordered_map>
194
+ extern "C" int64_t test_add (int64_t a, int64_t b);
164
195
  ```
165
-
166
- ## test_other_fn_@75fdd928ab58a8e3.cpp
196
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
167
197
  ```c++
168
198
  #include "test_other_fn_@75fdd928ab58a8e3.h"
169
199
  extern "C" int64_t test_other_fn (int64_t a, int64_t b)
170
200
  {
171
201
  return a - b;
172
202
  }
173
- ```
174
-
175
203
 
176
- ## test编译的函数_@5f8bb0506cab8a49.h
204
+ ```
205
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
177
206
  ```c++
178
207
  #include <cstdint>
179
208
  #include <string>
180
- extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
209
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
181
210
  ```
182
-
183
- ## test编译的函数_@5f8bb0506cab8a49.cpp
211
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
184
212
  ```c++
185
- #include "test编译的函数_@5f8bb0506cab8a49.h"
213
+ #include "test编译的函数_@3bf4501e0408a243.h"
186
214
  extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
187
215
  {
188
216
  return a * b;
189
217
  }
190
- ```
218
+
219
+ ```
220
+ ## 10. test编译的函数_@3bf4501e0408a243.h
221
+ ```c++
222
+ #include <cstdint>
223
+ #include <string>
224
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
225
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: l0n0lc
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -8,13 +8,54 @@ Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Dynamic: license-file
10
10
 
11
+
11
12
  # 将python函数翻译为c++函数并运行
12
- ## 安装
13
+ ## 1. 安装
13
14
  ```
14
15
  pip install l0n0lc
15
16
  ```
17
+ ## 2. 运行hello_world.py
18
+ ```
19
+ uv run tests/hello_world.py
20
+ # 输入: b'1\n2\n100\n101\n'
21
+ ```
22
+ ```bash
23
+ 输出map:
24
+ c 3
25
+ a 1
26
+ b 2
27
+ 输出list:
28
+ 0 134
29
+ 1 3
30
+ 2 2
31
+ Hello World 13 3
32
+ test_other_fn 10
33
+ test编译的函数 39
34
+ 请输入>>>输入的 1 小于等于100
35
+ 请输入>>>输入的 2 小于等于100
36
+ 请输入>>>输入的 100 小于等于100
37
+ 请输入>>>结果: 241
38
+
39
+ ```
40
+
41
+ ## 3. 查看输出文件
42
+ ```bash
43
+ ls -al ./l0n0lcoutput
44
+ total 96
45
+ drwxr-xr-x 2 root root 4096 Sep 12 01:42 .
46
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:14 ..
47
+ -rw-r--r-- 1 root root 1233 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.cpp
48
+ -rw-r--r-- 1 root root 246 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.h
49
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:42 test_add_@3ecbfe0013e83ebc.so
50
+ -rw-r--r-- 1 root root 121 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.cpp
51
+ -rw-r--r-- 1 root root 93 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.h
52
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:42 test_other_fn_@75fdd928ab58a8e3.so
53
+ -rw-r--r-- 1 root root 185 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.cpp
54
+ -rw-r--r-- 1 root root 151 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.h
55
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:14 test编译的函数_@3bf4501e0408a243.so
16
56
 
17
- ## hello_world.py
57
+ ```
58
+ ## 4. hello_world.py
18
59
  ```python
19
60
  import l0n0lc as lc
20
61
  import math
@@ -34,6 +75,15 @@ def cpp_cout(*args):
34
75
  return code
35
76
 
36
77
 
78
+ def py_cin(v):
79
+ pass
80
+
81
+
82
+ @lc.映射函数(py_cin, ['<iostream>'])
83
+ def cpp_cin(v):
84
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
85
+
86
+
37
87
  @lc.直接调用函数
38
88
  def test_直接调用():
39
89
  return 123
@@ -43,7 +93,7 @@ def test_other_fn(a: int, b: int) -> int:
43
93
  return a - b
44
94
 
45
95
 
46
- @lc.jit(每次运行都重新编译=True)
96
+ @lc.jit()
47
97
  def test编译的函数(a: int, b: int) -> int:
48
98
  return a * b
49
99
 
@@ -70,60 +120,22 @@ def test_add(a: int, b: int) -> int:
70
120
  print('Hello World', a, b)
71
121
  print('test_other_fn', test_other_fn(a, b))
72
122
  print('test编译的函数', test编译的函数(a, b))
73
- return a + b + 1 + test_直接调用()
123
+ v = 0
124
+ while (1):
125
+ py_cin(v)
126
+ if v > 100:
127
+ break
128
+ else:
129
+ print('输入的', v, '小于等于100')
130
+ return a + b + 1 + test_直接调用() + v
74
131
 
75
132
 
76
133
  print('结果:', test_add(1, 3))
77
- ```
78
- ## 执行hello_world.py
79
- ```bash
80
- $ python hello_world.py
81
- 输出map:
82
- c 3
83
- a 1
84
- b 2
85
- 输出list:
86
- 0 134
87
- 1 3
88
- 2 2
89
- Hello World 13 3
90
- test_other_fn 10
91
- test编译的函数 39
92
- 结果: 140
93
- ```
94
- ## 查看生成的c++代码文件
95
- ```bash
96
- $ ls -al l0n0lcoutput/
97
- total 96
98
- drwxr-xr-x 2 root root 4096 Sep 12 00:25 .
99
- drwxrwxrwx 11 1000 1000 4096 Sep 11 23:45 ..
100
- -rw-r--r-- 1 root root 994 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.cpp
101
- -rw-r--r-- 1 root root 246 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.h
102
- -rwxr-xr-x 1 root root 29744 Sep 12 00:25 test_add_@6ddf6c9d797f5d1b.so
103
- -rw-r--r-- 1 root root 121 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.cpp
104
- -rw-r--r-- 1 root root 93 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.h
105
- -rwxr-xr-x 1 root root 15616 Sep 12 00:25 test_other_fn_@75fdd928ab58a8e3.so
106
- -rw-r--r-- 1 root root 185 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.cpp
107
- -rw-r--r-- 1 root root 151 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.h
108
- -rwxr-xr-x 1 root root 15656 Sep 12 00:25 test编译的函数_@5f8bb0506cab8a49.so
109
- ```
110
-
111
- ## test_add_@6ddf6c9d797f5d1b.h
112
134
 
113
- ```c++
114
- #include "test_other_fn_@75fdd928ab58a8e3.h"
115
- #include "test编译的函数_@5f8bb0506cab8a49.h"
116
- #include <cmath>
117
- #include <cstdint>
118
- #include <iostream>
119
- #include <string>
120
- #include <unordered_map>
121
- extern "C" int64_t test_add (int64_t a, int64_t b);
122
135
  ```
123
-
124
- ## test_add_@6ddf6c9d797f5d1b.cpp
136
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
125
137
  ```c++
126
- #include "test_add_@6ddf6c9d797f5d1b.h"
138
+ #include "test_add_@3ecbfe0013e83ebc.h"
127
139
  extern "C" int64_t test_add (int64_t a, int64_t b)
128
140
  {
129
141
  if ((a > 1))
@@ -161,40 +173,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
161
173
  std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
162
174
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
163
175
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
164
- return a + b + 1 + 123;
176
+ auto v = 0;
177
+ while (1)
178
+ {
179
+ std::cout << u8"请输入>>>"; std::cin >> v;
180
+ if ((v > 100))
181
+ {
182
+ break;
183
+ }
184
+
185
+ {
186
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
187
+ }
188
+
189
+ }
190
+
191
+ return a + b + 1 + 123 + v;
165
192
  }
166
193
 
167
194
  ```
168
-
169
- ## test_other_fn_@75fdd928ab58a8e3.h
195
+ ## 6. test_add_@3ecbfe0013e83ebc.h
170
196
  ```c++
197
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
198
+ #include "test编译的函数_@3bf4501e0408a243.h"
199
+ #include <cmath>
171
200
  #include <cstdint>
201
+ #include <iostream>
172
202
  #include <string>
173
- extern "C" int64_t test_other_fn (int64_t a, int64_t b);
203
+ #include <unordered_map>
204
+ extern "C" int64_t test_add (int64_t a, int64_t b);
174
205
  ```
175
-
176
- ## test_other_fn_@75fdd928ab58a8e3.cpp
206
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
177
207
  ```c++
178
208
  #include "test_other_fn_@75fdd928ab58a8e3.h"
179
209
  extern "C" int64_t test_other_fn (int64_t a, int64_t b)
180
210
  {
181
211
  return a - b;
182
212
  }
183
- ```
184
213
 
185
-
186
- ## test编译的函数_@5f8bb0506cab8a49.h
214
+ ```
215
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
187
216
  ```c++
188
217
  #include <cstdint>
189
218
  #include <string>
190
- extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
219
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
191
220
  ```
192
-
193
- ## test编译的函数_@5f8bb0506cab8a49.cpp
221
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
194
222
  ```c++
195
- #include "test编译的函数_@5f8bb0506cab8a49.h"
223
+ #include "test编译的函数_@3bf4501e0408a243.h"
196
224
  extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
197
225
  {
198
226
  return a * b;
199
227
  }
228
+
229
+ ```
230
+ ## 10. test编译的函数_@3bf4501e0408a243.h
231
+ ```c++
232
+ #include <cstdint>
233
+ #include <string>
234
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
200
235
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "l0n0lc"
3
- version = "0.8.0"
3
+ version = "0.8.1"
4
4
  description = "一个将python函数翻译为c++函数并运行的jit编译器"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes