l0n0lc 0.8.0__py3-none-any.whl → 0.8.1__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.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
  ```
@@ -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.1.dist-info/licenses/LICENSE,sha256=1L-MAjulZ3kpbYwsJtlXpDVITRxykna2Ecg_521YfkA,1093
9
+ l0n0lc-0.8.1.dist-info/METADATA,sha256=AUjv6PdArE-jazXeyTCfJH41AmAOlyLyDvn6T9C7q0o,5512
10
+ l0n0lc-0.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ l0n0lc-0.8.1.dist-info/top_level.txt,sha256=Q21D_eEY_-xgRUPwATGp9YDKSBO4w_7MI2MYxQI1aT4,7
12
+ l0n0lc-0.8.1.dist-info/RECORD,,
File without changes