l0n0lc 0.8.1__tar.gz → 0.8.3__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.1
3
+ Version: 0.8.3
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -14,48 +14,7 @@ Dynamic: license-file
14
14
  ```
15
15
  pip install l0n0lc
16
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
56
-
57
- ```
58
- ## 4. hello_world.py
17
+ ## 2. hello_world.py
59
18
  ```python
60
19
  import l0n0lc as lc
61
20
  import math
@@ -121,7 +80,8 @@ def test_add(a: int, b: int) -> int:
121
80
  print('test_other_fn', test_other_fn(a, b))
122
81
  print('test编译的函数', test编译的函数(a, b))
123
82
  v = 0
124
- while (1):
83
+ vv = True
84
+ while (vv):
125
85
  py_cin(v)
126
86
  if v > 100:
127
87
  break
@@ -133,9 +93,51 @@ def test_add(a: int, b: int) -> int:
133
93
  print('结果:', test_add(1, 3))
134
94
 
135
95
  ```
136
- ## 5. test_add_@3ecbfe0013e83ebc.cpp
96
+
97
+ ## 3. 运行hello_world.py
98
+ ```
99
+ uv run tests/hello_world.py
100
+ # 输入: b'1\n2\n100\n101\n'
101
+ ```
102
+ ```bash
103
+ 输出map:
104
+ c 3
105
+ a 1
106
+ b 2
107
+ 输出list:
108
+ 0 134
109
+ 1 3
110
+ 2 2
111
+ Hello World 13 3
112
+ test_other_fn 10
113
+ test编译的函数 39
114
+ 请输入>>>输入的 1 小于等于100
115
+ 请输入>>>输入的 2 小于等于100
116
+ 请输入>>>输入的 100 小于等于100
117
+ 请输入>>>结果: 241
118
+
119
+ ```
120
+
121
+ ## 4. 查看输出文件
122
+ ```bash
123
+ ls -al ./l0n0lcoutput
124
+ total 96
125
+ drwxr-xr-x 2 root root 4096 Sep 16 01:38 .
126
+ drwxrwxrwx 11 1000 1000 4096 Sep 16 01:36 ..
127
+ -rw-r--r-- 1 root root 1252 Sep 16 01:38 test_add_@05ade4b088e9b383.cpp
128
+ -rw-r--r-- 1 root root 246 Sep 16 01:38 test_add_@05ade4b088e9b383.h
129
+ -rwxr-xr-x 1 root root 29904 Sep 16 01:38 test_add_@05ade4b088e9b383.so
130
+ -rw-r--r-- 1 root root 121 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.cpp
131
+ -rw-r--r-- 1 root root 93 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.h
132
+ -rwxr-xr-x 1 root root 15616 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.so
133
+ -rw-r--r-- 1 root root 185 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.cpp
134
+ -rw-r--r-- 1 root root 151 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.h
135
+ -rwxr-xr-x 1 root root 15656 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.so
136
+
137
+ ```
138
+ ## 5. test_add_@05ade4b088e9b383.cpp
137
139
  ```c++
138
- #include "test_add_@3ecbfe0013e83ebc.h"
140
+ #include "test_add_@05ade4b088e9b383.h"
139
141
  extern "C" int64_t test_add (int64_t a, int64_t b)
140
142
  {
141
143
  if ((a > 1))
@@ -174,7 +176,8 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
174
176
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
175
177
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
176
178
  auto v = 0;
177
- while (1)
179
+ auto vv = true;
180
+ while (vv)
178
181
  {
179
182
  std::cout << u8"请输入>>>"; std::cin >> v;
180
183
  if ((v > 100))
@@ -192,7 +195,7 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
192
195
  }
193
196
 
194
197
  ```
195
- ## 6. test_add_@3ecbfe0013e83ebc.h
198
+ ## 6. test_add_@05ade4b088e9b383.h
196
199
  ```c++
197
200
  #include "test_other_fn_@75fdd928ab58a8e3.h"
198
201
  #include "test编译的函数_@3bf4501e0408a243.h"
@@ -4,48 +4,7 @@
4
4
  ```
5
5
  pip install l0n0lc
6
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
46
-
47
- ```
48
- ## 4. hello_world.py
7
+ ## 2. hello_world.py
49
8
  ```python
50
9
  import l0n0lc as lc
51
10
  import math
@@ -111,7 +70,8 @@ def test_add(a: int, b: int) -> int:
111
70
  print('test_other_fn', test_other_fn(a, b))
112
71
  print('test编译的函数', test编译的函数(a, b))
113
72
  v = 0
114
- while (1):
73
+ vv = True
74
+ while (vv):
115
75
  py_cin(v)
116
76
  if v > 100:
117
77
  break
@@ -123,9 +83,51 @@ def test_add(a: int, b: int) -> int:
123
83
  print('结果:', test_add(1, 3))
124
84
 
125
85
  ```
126
- ## 5. test_add_@3ecbfe0013e83ebc.cpp
86
+
87
+ ## 3. 运行hello_world.py
88
+ ```
89
+ uv run tests/hello_world.py
90
+ # 输入: b'1\n2\n100\n101\n'
91
+ ```
92
+ ```bash
93
+ 输出map:
94
+ c 3
95
+ a 1
96
+ b 2
97
+ 输出list:
98
+ 0 134
99
+ 1 3
100
+ 2 2
101
+ Hello World 13 3
102
+ test_other_fn 10
103
+ test编译的函数 39
104
+ 请输入>>>输入的 1 小于等于100
105
+ 请输入>>>输入的 2 小于等于100
106
+ 请输入>>>输入的 100 小于等于100
107
+ 请输入>>>结果: 241
108
+
109
+ ```
110
+
111
+ ## 4. 查看输出文件
112
+ ```bash
113
+ ls -al ./l0n0lcoutput
114
+ total 96
115
+ drwxr-xr-x 2 root root 4096 Sep 16 01:38 .
116
+ drwxrwxrwx 11 1000 1000 4096 Sep 16 01:36 ..
117
+ -rw-r--r-- 1 root root 1252 Sep 16 01:38 test_add_@05ade4b088e9b383.cpp
118
+ -rw-r--r-- 1 root root 246 Sep 16 01:38 test_add_@05ade4b088e9b383.h
119
+ -rwxr-xr-x 1 root root 29904 Sep 16 01:38 test_add_@05ade4b088e9b383.so
120
+ -rw-r--r-- 1 root root 121 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.cpp
121
+ -rw-r--r-- 1 root root 93 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.h
122
+ -rwxr-xr-x 1 root root 15616 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.so
123
+ -rw-r--r-- 1 root root 185 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.cpp
124
+ -rw-r--r-- 1 root root 151 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.h
125
+ -rwxr-xr-x 1 root root 15656 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.so
126
+
127
+ ```
128
+ ## 5. test_add_@05ade4b088e9b383.cpp
127
129
  ```c++
128
- #include "test_add_@3ecbfe0013e83ebc.h"
130
+ #include "test_add_@05ade4b088e9b383.h"
129
131
  extern "C" int64_t test_add (int64_t a, int64_t b)
130
132
  {
131
133
  if ((a > 1))
@@ -164,7 +166,8 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
164
166
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
165
167
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
166
168
  auto v = 0;
167
- while (1)
169
+ auto vv = true;
170
+ while (vv)
168
171
  {
169
172
  std::cout << u8"请输入>>>"; std::cin >> v;
170
173
  if ((v > 100))
@@ -182,7 +185,7 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
182
185
  }
183
186
 
184
187
  ```
185
- ## 6. test_add_@3ecbfe0013e83ebc.h
188
+ ## 6. test_add_@05ade4b088e9b383.h
186
189
  ```c++
187
190
  #include "test_other_fn_@75fdd928ab58a8e3.h"
188
191
  #include "test编译的函数_@3bf4501e0408a243.h"
@@ -71,6 +71,16 @@ class c函数调用:
71
71
  return f'{self.函数名}({self.参数字符串})'
72
72
 
73
73
 
74
+ class c布尔:
75
+ def __init__(self, v) -> None:
76
+ self.v = v
77
+
78
+ def __str__(self) -> str:
79
+ if self.v:
80
+ return 'true'
81
+ return 'false'
82
+
83
+
74
84
  class py2cpp编译器(ast.NodeVisitor):
75
85
  def __init__(self, 被编译的函数: Callable, c编译器) -> None:
76
86
  self.被编译的函数 = 被编译的函数
@@ -158,6 +168,8 @@ class py2cpp编译器(ast.NodeVisitor):
158
168
 
159
169
  def 获取值(self, value):
160
170
  if isinstance(value, ast.Constant):
171
+ if isinstance(value.value, bool):
172
+ return c布尔(value.value)
161
173
  return value.value
162
174
 
163
175
  if isinstance(value, ast.Name):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: l0n0lc
3
- Version: 0.8.1
3
+ Version: 0.8.3
4
4
  Summary: 一个将python函数翻译为c++函数并运行的jit编译器
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Requires-Python: >=3.10
@@ -14,48 +14,7 @@ Dynamic: license-file
14
14
  ```
15
15
  pip install l0n0lc
16
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
56
-
57
- ```
58
- ## 4. hello_world.py
17
+ ## 2. hello_world.py
59
18
  ```python
60
19
  import l0n0lc as lc
61
20
  import math
@@ -121,7 +80,8 @@ def test_add(a: int, b: int) -> int:
121
80
  print('test_other_fn', test_other_fn(a, b))
122
81
  print('test编译的函数', test编译的函数(a, b))
123
82
  v = 0
124
- while (1):
83
+ vv = True
84
+ while (vv):
125
85
  py_cin(v)
126
86
  if v > 100:
127
87
  break
@@ -133,9 +93,51 @@ def test_add(a: int, b: int) -> int:
133
93
  print('结果:', test_add(1, 3))
134
94
 
135
95
  ```
136
- ## 5. test_add_@3ecbfe0013e83ebc.cpp
96
+
97
+ ## 3. 运行hello_world.py
98
+ ```
99
+ uv run tests/hello_world.py
100
+ # 输入: b'1\n2\n100\n101\n'
101
+ ```
102
+ ```bash
103
+ 输出map:
104
+ c 3
105
+ a 1
106
+ b 2
107
+ 输出list:
108
+ 0 134
109
+ 1 3
110
+ 2 2
111
+ Hello World 13 3
112
+ test_other_fn 10
113
+ test编译的函数 39
114
+ 请输入>>>输入的 1 小于等于100
115
+ 请输入>>>输入的 2 小于等于100
116
+ 请输入>>>输入的 100 小于等于100
117
+ 请输入>>>结果: 241
118
+
119
+ ```
120
+
121
+ ## 4. 查看输出文件
122
+ ```bash
123
+ ls -al ./l0n0lcoutput
124
+ total 96
125
+ drwxr-xr-x 2 root root 4096 Sep 16 01:38 .
126
+ drwxrwxrwx 11 1000 1000 4096 Sep 16 01:36 ..
127
+ -rw-r--r-- 1 root root 1252 Sep 16 01:38 test_add_@05ade4b088e9b383.cpp
128
+ -rw-r--r-- 1 root root 246 Sep 16 01:38 test_add_@05ade4b088e9b383.h
129
+ -rwxr-xr-x 1 root root 29904 Sep 16 01:38 test_add_@05ade4b088e9b383.so
130
+ -rw-r--r-- 1 root root 121 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.cpp
131
+ -rw-r--r-- 1 root root 93 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.h
132
+ -rwxr-xr-x 1 root root 15616 Sep 16 01:38 test_other_fn_@75fdd928ab58a8e3.so
133
+ -rw-r--r-- 1 root root 185 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.cpp
134
+ -rw-r--r-- 1 root root 151 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.h
135
+ -rwxr-xr-x 1 root root 15656 Sep 16 01:36 test编译的函数_@3bf4501e0408a243.so
136
+
137
+ ```
138
+ ## 5. test_add_@05ade4b088e9b383.cpp
137
139
  ```c++
138
- #include "test_add_@3ecbfe0013e83ebc.h"
140
+ #include "test_add_@05ade4b088e9b383.h"
139
141
  extern "C" int64_t test_add (int64_t a, int64_t b)
140
142
  {
141
143
  if ((a > 1))
@@ -174,7 +176,8 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
174
176
  std::cout<< u8"test_other_fn" << " "<< test_other_fn(a,b) << " "<< std::endl;
175
177
  std::cout<< u8"test编译的函数" << " "<< function_74657374e7bc96e8af91e79a84e587bde695b0(a,b) << " "<< std::endl;
176
178
  auto v = 0;
177
- while (1)
179
+ auto vv = true;
180
+ while (vv)
178
181
  {
179
182
  std::cout << u8"请输入>>>"; std::cin >> v;
180
183
  if ((v > 100))
@@ -192,7 +195,7 @@ extern "C" int64_t test_add (int64_t a, int64_t b)
192
195
  }
193
196
 
194
197
  ```
195
- ## 6. test_add_@3ecbfe0013e83ebc.h
198
+ ## 6. test_add_@05ade4b088e9b383.h
196
199
  ```c++
197
200
  #include "test_other_fn_@75fdd928ab58a8e3.h"
198
201
  #include "test编译的函数_@3bf4501e0408a243.h"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "l0n0lc"
3
- version = "0.8.1"
3
+ version = "0.8.3"
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