l0n0lc 0.8.0__py3-none-any.whl → 0.8.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: l0n0lc
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -8,13 +8,13 @@ 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
  ```
16
-
17
- ## hello_world.py
17
+ ## 2. hello_world.py
18
18
  ```python
19
19
  import l0n0lc as lc
20
20
  import math
@@ -34,6 +34,15 @@ def cpp_cout(*args):
34
34
  return code
35
35
 
36
36
 
37
+ def py_cin(v):
38
+ pass
39
+
40
+
41
+ @lc.映射函数(py_cin, ['<iostream>'])
42
+ def cpp_cin(v):
43
+ return f'std::cout << u8"请输入>>>"; std::cin >> {v};'
44
+
45
+
37
46
  @lc.直接调用函数
38
47
  def test_直接调用():
39
48
  return 123
@@ -43,7 +52,7 @@ def test_other_fn(a: int, b: int) -> int:
43
52
  return a - b
44
53
 
45
54
 
46
- @lc.jit(每次运行都重新编译=True)
55
+ @lc.jit()
47
56
  def test编译的函数(a: int, b: int) -> int:
48
57
  return a * b
49
58
 
@@ -70,14 +79,26 @@ def test_add(a: int, b: int) -> int:
70
79
  print('Hello World', a, b)
71
80
  print('test_other_fn', test_other_fn(a, b))
72
81
  print('test编译的函数', test编译的函数(a, b))
73
- return a + b + 1 + test_直接调用()
82
+ v = 0
83
+ while (1):
84
+ py_cin(v)
85
+ if v > 100:
86
+ break
87
+ else:
88
+ print('输入的', v, '小于等于100')
89
+ return a + b + 1 + test_直接调用() + v
74
90
 
75
91
 
76
92
  print('结果:', test_add(1, 3))
93
+
94
+ ```
95
+
96
+ ## 3. 运行hello_world.py
97
+ ```
98
+ uv run tests/hello_world.py
99
+ # 输入: b'1\n2\n100\n101\n'
77
100
  ```
78
- ## 执行hello_world.py
79
101
  ```bash
80
- $ python hello_world.py
81
102
  输出map:
82
103
  c 3
83
104
  a 1
@@ -89,41 +110,33 @@ b 2
89
110
  Hello World 13 3
90
111
  test_other_fn 10
91
112
  test编译的函数 39
92
- 结果: 140
113
+ 请输入>>>输入的 1 小于等于100
114
+ 请输入>>>输入的 2 小于等于100
115
+ 请输入>>>输入的 100 小于等于100
116
+ 请输入>>>结果: 241
117
+
93
118
  ```
94
- ## 查看生成的c++代码文件
119
+
120
+ ## 4. 查看输出文件
95
121
  ```bash
96
- $ ls -al l0n0lcoutput/
122
+ ls -al ./l0n0lcoutput
97
123
  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
124
+ drwxr-xr-x 2 root root 4096 Sep 12 01:46 .
125
+ drwxrwxrwx 11 1000 1000 4096 Sep 12 01:46 ..
126
+ -rw-r--r-- 1 root root 1233 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.cpp
127
+ -rw-r--r-- 1 root root 246 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.h
128
+ -rwxr-xr-x 1 root root 29904 Sep 12 01:46 test_add_@3ecbfe0013e83ebc.so
129
+ -rw-r--r-- 1 root root 121 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.cpp
130
+ -rw-r--r-- 1 root root 93 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.h
131
+ -rwxr-xr-x 1 root root 15616 Sep 12 01:46 test_other_fn_@75fdd928ab58a8e3.so
132
+ -rw-r--r-- 1 root root 185 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.cpp
133
+ -rw-r--r-- 1 root root 151 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.h
134
+ -rwxr-xr-x 1 root root 15656 Sep 12 01:46 test编译的函数_@3bf4501e0408a243.so
112
135
 
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
136
  ```
123
-
124
- ## test_add_@6ddf6c9d797f5d1b.cpp
137
+ ## 5. test_add_@3ecbfe0013e83ebc.cpp
125
138
  ```c++
126
- #include "test_add_@6ddf6c9d797f5d1b.h"
139
+ #include "test_add_@3ecbfe0013e83ebc.h"
127
140
  extern "C" int64_t test_add (int64_t a, int64_t b)
128
141
  {
129
142
  if ((a > 1))
@@ -161,40 +174,63 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
161
174
  std::cout<< u8"Hello World" << " "<< a << " "<< b << " "<< std::endl;
162
175
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
163
176
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
164
- return a + b + 1 + 123;
177
+ auto v = 0;
178
+ while (1)
179
+ {
180
+ std::cout << u8"请输入>>>"; std::cin >> v;
181
+ if ((v > 100))
182
+ {
183
+ break;
184
+ }
185
+
186
+ {
187
+ std::cout<< u8"输入的" << " "<< v << " "<< u8"小于等于100" << " "<< std::endl;
188
+ }
189
+
190
+ }
191
+
192
+ return a + b + 1 + 123 + v;
165
193
  }
166
194
 
167
195
  ```
168
-
169
- ## test_other_fn_@75fdd928ab58a8e3.h
196
+ ## 6. test_add_@3ecbfe0013e83ebc.h
170
197
  ```c++
198
+ #include "test_other_fn_@75fdd928ab58a8e3.h"
199
+ #include "test编译的函数_@3bf4501e0408a243.h"
200
+ #include <cmath>
171
201
  #include <cstdint>
202
+ #include <iostream>
172
203
  #include <string>
173
- extern "C" int64_t test_other_fn (int64_t a, int64_t b);
204
+ #include <unordered_map>
205
+ extern "C" int64_t test_add (int64_t a, int64_t b);
174
206
  ```
175
-
176
- ## test_other_fn_@75fdd928ab58a8e3.cpp
207
+ ## 7. test_other_fn_@75fdd928ab58a8e3.cpp
177
208
  ```c++
178
209
  #include "test_other_fn_@75fdd928ab58a8e3.h"
179
210
  extern "C" int64_t test_other_fn (int64_t a, int64_t b)
180
211
  {
181
212
  return a - b;
182
213
  }
183
- ```
184
-
185
214
 
186
- ## test编译的函数_@5f8bb0506cab8a49.h
215
+ ```
216
+ ## 8. test_other_fn_@75fdd928ab58a8e3.h
187
217
  ```c++
188
218
  #include <cstdint>
189
219
  #include <string>
190
- extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
220
+ extern "C" int64_t test_other_fn (int64_t a, int64_t b);
191
221
  ```
192
-
193
- ## test编译的函数_@5f8bb0506cab8a49.cpp
222
+ ## 9. test编译的函数_@3bf4501e0408a243.cpp
194
223
  ```c++
195
- #include "test编译的函数_@5f8bb0506cab8a49.h"
224
+ #include "test编译的函数_@3bf4501e0408a243.h"
196
225
  extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b)
197
226
  {
198
227
  return a * b;
199
228
  }
229
+
230
+ ```
231
+ ## 10. test编译的函数_@3bf4501e0408a243.h
232
+ ```c++
233
+ #include <cstdint>
234
+ #include <string>
235
+ extern "C" int64_t /*test编译的函数*/ function_74657374e7bc96e8af91e79a84e587bde695b0 (int64_t a, int64_t b);
200
236
  ```
@@ -5,8 +5,8 @@ l0n0lc/c基础处理.py,sha256=FMauoVx4-33JXl4OLpUl1D6NCkLjk6yBH7do9WnT0Wg,5671
5
5
  l0n0lc/jit.py,sha256=0HFfsFG531wHFwHaEsscJE2RiUe1D9nfutn8CfqWaV4,23676
6
6
  l0n0lc/编译.py,sha256=Ty4gPDHAB1jn8LgnE4w3R06bOAEeYr8iwqahYf6QeHI,2154
7
7
  l0n0lc/通用.py,sha256=O_Y4bbW1WzHCJkibxAy9WGACv-aEZJLG-fEeVBcAbBQ,3649
8
- l0n0lc-0.8.0.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
9
- l0n0lc-0.8.0.dist-info/METADATA,sha256=BbYwry7TI-Z-iwHmyA2-Zg7vtiqfRwFvlWLSwiPUQ30,4812
10
- l0n0lc-0.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- l0n0lc-0.8.0.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
12
- l0n0lc-0.8.0.dist-info/RECORD,,
8
+ l0n0lc-0.8.2.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
9
+ l0n0lc-0.8.2.dist-info/METADATA,sha256=cBr_CPYia-yx6SsxozjqPETscjmNs6mY_97p38NUlYA,5513
10
+ l0n0lc-0.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ l0n0lc-0.8.2.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
12
+ l0n0lc-0.8.2.dist-info/RECORD,,
File without changes