@@ -11,12 +11,12 @@ categories: [技术思考]
1111
1212** 新建空白测试用文件夹TestForPyCache并进入**
1313
14- ![ 新建文件夹TestForPyCache] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/4169ac9af5ba48abbddc7974741472f2.png ) ![ 进入测试用文件夹] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/3a997d70d29948a79e2f0086108c707f.png )
14+ ![ 新建文件夹TestForPyCache] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/4169ac9af5ba48abbddc7974741472f2.png ) ![ 进入测试用文件夹] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/3a997d70d29948a79e2f0086108c707f.png )
1515
1616** 初始化Git仓库**
17- ![ 初始化Git仓库] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/dcced958c5fc4f2c80fa9d615919c85d.png )
17+ ![ 初始化Git仓库] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/dcced958c5fc4f2c80fa9d615919c85d.png )
1818** 新建空白Py文件**
19- ![ 新建空白Py文件] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/99482b978a784ace980b051538887ea5.png )
19+ ![ 新建空白Py文件] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/99482b978a784ace980b051538887ea5.png )
2020
2121``` bash
2222fsutil file createnew main.py 0
@@ -28,10 +28,10 @@ fsutil file createnew main.py 0
2828
2929新建MyModel文件夹
3030
31- ![ 新建MyModel文件夹] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/b7e0ef89d40e4c5dbea8f626cdbbc295.png )
31+ ![ 新建MyModel文件夹] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/b7e0ef89d40e4c5dbea8f626cdbbc295.png )
3232并在新建的文件夹中新建两个空白文件``` __init__.py ``` 和``` GetSum.py ```
3333
34- ![ 新建类中文件] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/81f5acb778964ebda2da52d442d43928.png )
34+ ![ 新建类中文件] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/81f5acb778964ebda2da52d442d43928.png )
3535
3636``` bash
3737fsutil file createnew .\M yModel\_ _init__.py 0
@@ -42,7 +42,7 @@ fsutil file createnew .\MyModel\GetSum.py 0
4242
4343MyModel/GetSum.py:
4444
45- ![ GetSum.py] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/2e97c7230b0f41989ed1c8e31412b2ff.png )
45+ ![ GetSum.py] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/2e97c7230b0f41989ed1c8e31412b2ff.png )
4646这里使用一段非常简单的代码进行测试
4747
4848``` python
@@ -55,7 +55,7 @@ def getSumN(n: int) -> int:
5555```
5656
5757main.py:
58- ![ main.py] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/89e44579e76e4d45ab67e1744601b26b.png )
58+ ![ main.py] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/89e44579e76e4d45ab67e1744601b26b.png )
5959``` python
6060from MyModel import GetSum
6161
@@ -68,53 +68,53 @@ print(result)
6868
6969** 提交到版本库**
7070
71- ![ 提交到版本库] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/d63fe54698254eb5a5a51c0ecf8629a3.png )
71+ ![ 提交到版本库] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/d63fe54698254eb5a5a51c0ecf8629a3.png )
7272
7373可以看到有一次提交记录
7474
7575并且当前工作区无改动
76- ![ 当前工作区无改动] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/132df6921de64b45b3118b8d1896fab7.png )
76+ ![ 当前工作区无改动] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/132df6921de64b45b3118b8d1896fab7.png )
7777
7878** 运行一次main.py**
7979
8080
81- ![ 运行一次] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/c490775fdfec48afb0403a2e4a2759f9.png )
81+ ![ 运行一次] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/c490775fdfec48afb0403a2e4a2759f9.png )
8282
8383这次输入``` 100000000 ```
8484
8585可以看到工作区有文件变动,新增了``` MyModel/__pycache__/ ``` 文件夹
8686
87- ![ 文件变动,MyModel/__ pycache__ /] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/d97a5af15dd44ef69d5a7be1e5c197c3.png )
87+ ![ 文件变动,MyModel/__ pycache__ /] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/d97a5af15dd44ef69d5a7be1e5c197c3.png )
8888** 同样添加到版本库**
8989
90- ![ 将Cache添加到版本库] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/5c52fb641dd44fbf902d298753b92cd0.png )
90+ ![ 将Cache添加到版本库] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/5c52fb641dd44fbf902d298753b92cd0.png )
9191
9292可以看到一共有两条提交记录,且工作区无改动
9393
9494** 那么,运行其他输入,PyCache会随之改变吗?**
9595
9696再次运行``` main.py ```
97- ![ 再次运行main.py] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/690a97083a964a82802ef96cb2abd3c0.png )
97+ ![ 再次运行main.py] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/690a97083a964a82802ef96cb2abd3c0.png )
9898这次输入值``` 50000000 ```
9999
100100** 查看工作区文件状态**
101101
102- ![ 发现工作区无改动] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/6dc111f054224ed5b0bec9edf1ce1aac.png )
102+ ![ 发现工作区无改动] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/6dc111f054224ed5b0bec9edf1ce1aac.png )
103103发现工作区无改动
104104
105105** 这就说明每次运行不同输入可能不会导致__ pycache__ 随之进行多次改变**
106106
107107我电脑上Python的版本为3.9.4
108108
109- ![ Python版本] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/f51862280523486683f13791133f8260.png )
109+ ![ Python版本] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/f51862280523486683f13791133f8260.png )
110110查看官方文档:[ https://docs.python.org/zh-cn/3.9/tutorial/modules.html?highlight=__pycache __ ] ( https://docs.python.org/zh-cn/3.9/tutorial/modules.html?highlight=__pycache__ )
111111
112- ![ 官方文档] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/22923d72a1a94e57b53ab51661da0bc3.png )
112+ ![ 官方文档] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/22923d72a1a94e57b53ab51661da0bc3.png )
113113点击蓝色链接``` PEP 3147 ``` :[ https://peps.python.org/pep-3147/ ] ( https://peps.python.org/pep-3147/ )
114114
115115即可看到pycache创建流程图
116116
117- ![ pycache创建流程图] ( https://cors.tisfy.eu.org /https://img-blog.csdnimg.cn/25737ed5801d4ce696519775e4f3587e.png )
117+ ![ pycache创建流程图] ( https://cors.letmefly.xyz /https://img-blog.csdnimg.cn/25737ed5801d4ce696519775e4f3587e.png )
118118(图源:[ https://peps.python.org/_images/pep-3147-1.png ] ( https://peps.python.org/_images/pep-3147-1.png ) )
119119
120120只有当“pycache/xx.pyc与源文件不符”时,才会重新编译生成``` pycache ```
0 commit comments