[Python learning manual notes] 001. Preface to Python

Gao Yang, who would not be named 2020-11-10 00:10:11
python learning manual notes preface

001.python Preface


This series of articles is my personal study 《python Learning manual ( The fifth edition )》 Learning notes of , Most of them are the summary and personal understanding of the book , A small part of the content is the extension of relevant knowledge points .

For non-commercial use, please indicate the author and source ; Please contact me for commercial use ([email protected]) Get permission .


About python Analysis of advantages and disadvantages

  • python High readability , Transplantation is good
  • The code is concise , Complete the same problem compared to java and C++, The amount of code is its 1/5~1/3
  • Efficiency is relative C Language is called poor , But it's not that bad
  • Open source , The community is very active , There are a lot of libraries that can be used directly by the government and the people

Here comes a question , About the advantages and disadvantages of open source . The following is personal understanding , Just for my personal opinion , Not authoritative

The advantages of open source

1) Open source , Relatively safe ;

2) Most open source software is free to use , Even if you need a paid license , The licensing fee is relatively low .

3) Open source software communities are generally more active , Software update iterations are fast .

About the shortcomings of open source software

1) Open source software is generally maintained by the community , The speed of iteration depends on the activity of the community . And it is possible that the software will stop maintenance due to the transfer of interest of developers or other factors , There is a certain risk

2) The use threshold of open source software is relatively high , Although the development cost is saved , But for deployment and maintenance personnel , A certain technical ability is required . such as , If you use commercial software , Later support can be done by the software provider , And open source software does not have a department responsible for responding , So the deployment and maintenance are all done by our own technicians . That's why open source software licenses are cheap and even free , Why many companies still choose commercial software . After all, the problem that can be solved with money , It's not a problem for the rich .

3) Open source software lacks dominant control , Open source community is a community with relatively high degree of freedom . Lack of absolute dominance . This is because the open source community is too active , This leads to the confusion of the version Branch .


python Operation process

python It's an explanatory language . That's right , But not exactly .

First of all, explain briefly the interpretive language and the compiler language :

  • Compiler language : Source code is compiler After a series of processing, the final product is strongly related to the processor instruction set , Binary files that can be executed directly by the processor .
    • Typical C Language and C++. In common use GCC Compiler for example , Executable binaries programmed from code are precompiled -> compile -> assembly -> Links and so on .
    • advantage : Compiled languages from source code to executable binaries are done before they run . So you don't need to process the source code again during execution , More efficient
    • shortcoming : alike , Because the source code has been processed into a processor strong binary before execution , So the portability is poor .
  • Explanatory language : Source code from Interpreter stay Runtime Translate sentence by sentence into machine code .
    • java,python And other languages belong to this category . But not strictly belong to this category . Because the so-called interpretive languages now have so-called optimization , The actual interpreter is not translating the source code , It's pretreated “ Partially Prepared Products ”
    • advantage : Translation is performed by the interpreter , Platforms are not relevant , Good portability .
    • shortcoming :
      • Low efficiency
      • Because there is an interpreter between the platform and the source code , So when deploying , You need to install the relevant operating environment, such as java Of jre etc. . Of course, it can also be packaged into corresponding binary files , image py2exe Such a tool , But it will also python Interpreter and source code ( Bytecode ) It's just packed at the same time .

python Operation process

  • Source code (.py) It is first processed into bytecode by the interpreter (.pyc)
  • Program runtime , Bytecode (.pyc) Interpreted by the interpreter as executable instructions

We will not talk about program execution for the time being , In the subsequent “ Lifetime series ” There may be related articles about this .

Here's a brief answer to bytecode .pyc File generation . First , Bytecode is platform independent , A low form of expression , It is mainly used to improve the running speed .

If python The interpreter has write permission , stay python3.2 Before , Bytecode files will be saved in a subdirectory under the source code directory __pycache__ in , And the interpreter version information will be saved in the corresponding .pyc In the file . stay python3.2 after , Bytecode files will still be saved in this directory , But the version information is saved in the file name , As shown in the figure below :


If python Interpreter does not have write permission , Bytecode files are also generated , But the file is saved in memory .

When to recompile

If the source code has not been modified , When the code is executed again ,python The interpreter will directly interpret the corresponding bytecode file without having to redo it " compile "( Be careful , The compiler is quoted .) Bytecode . So when to start again " compile " What about bytecode ? Two cases :

  • Source file changes : python The interpreter checks the last modified timestamp of the source and bytecode files , If the time is inconsistent , Then re " compile " Bytecode
  • Interpreter version changes : If the version of the interpreter used by bytecode file does not match the version of the interpreter used by the currently executing code , Then re " compile "

python Interpreter

python There are many implementations of the interpreter for , Here are some famous ones . Just get to know it , After all, most of them are standard ones CPython.

  • CPython: from ANSI C Language implementation , It's standard Python Interpreter .
    • We are python Downloaded from the official website python What is used in the suite is CPython
    • The fastest , Most complete , newest , The most robust
  • Jython: The purpose of this thing is to Python and Java Integrate , take Python Source code translated into Java In order to make it run in JVM On .
  • IronPython: and Jython almost , But this guy's purpose is to make python Running on the .net Under the framework .
  • Stackless: CPython Optimization for concurrency , The concept of coprocess is introduced
  • PyPy: use JIT(just in time) technology , It is said that it can be compared with python even to the extent that C Language is faster , In algorithm intensive and computing intensive scenarios, the performance is more outstanding .( I don't understand this , I dare not talk nonsense )

This article USES the mdnice Typesetting

本文为[Gao Yang, who would not be named]所创,转载请带上原文链接,感谢

  1. 利用Python爬虫获取招聘网站职位信息
  2. Using Python crawler to obtain job information of recruitment website
  3. Several highly rated Python libraries arrow, jsonpath, psutil and tenacity are recommended
  4. Python装饰器
  5. Python实现LDAP认证
  6. Python decorator
  7. Implementing LDAP authentication with Python
  8. Vscode configures Python development environment!
  9. In Python, how dare you say you can't log module? ️
  10. 我收藏的有关Python的电子书和资料
  11. python 中 lambda的一些tips
  12. python中字典的一些tips
  13. python 用生成器生成斐波那契数列
  14. python脚本转pyc踩了个坑。。。
  15. My collection of e-books and materials about Python
  16. Some tips of lambda in Python
  17. Some tips of dictionary in Python
  18. Using Python generator to generate Fibonacci sequence
  19. The conversion of Python script to PyC stepped on a pit...
  20. Python游戏开发,pygame模块,Python实现扫雷小游戏
  21. Python game development, pyGame module, python implementation of minesweeping games
  22. Python实用工具,email模块,Python实现邮件远程控制自己电脑
  23. Python utility, email module, python realizes mail remote control of its own computer
  24. 毫无头绪的自学Python,你可能连门槛都摸不到!【最佳学习路线】
  25. Python读取二进制文件代码方法解析
  26. Python字典的实现原理
  27. Without a clue, you may not even touch the threshold【 Best learning route]
  28. Parsing method of Python reading binary file code
  29. Implementation principle of Python dictionary
  30. You must know the function of pandas to parse JSON data - JSON_ normalize()
  31. Python实用案例,私人定制,Python自动化生成爱豆专属2021日历
  32. Python practical case, private customization, python automatic generation of Adu exclusive 2021 calendar
  33. 《Python实例》震惊了,用Python这么简单实现了聊天系统的脏话,广告检测
  34. "Python instance" was shocked and realized the dirty words and advertisement detection of the chat system in Python
  35. Convolutional neural network processing sequence for Python deep learning
  36. Python data structure and algorithm (1) -- enum type enum
  37. 超全大厂算法岗百问百答(推荐系统/机器学习/深度学习/C++/Spark/python)
  38. 【Python进阶】你真的明白NumPy中的ndarray吗?
  39. All questions and answers for algorithm posts of super large factories (recommended system / machine learning / deep learning / C + + / spark / Python)
  40. [advanced Python] do you really understand ndarray in numpy?
  41. 【Python进阶】Python进阶专栏栏主自述:不忘初心,砥砺前行
  42. [advanced Python] Python advanced column main readme: never forget the original intention and forge ahead
  43. python垃圾回收和缓存管理
  44. java调用Python程序
  45. java调用Python程序
  46. Python常用函数有哪些?Python基础入门课程
  47. Python garbage collection and cache management
  48. Java calling Python program
  49. Java calling Python program
  50. What functions are commonly used in Python? Introduction to Python Basics
  51. Python basic knowledge
  52. Anaconda5.2 安装 Python 库(MySQLdb)的方法
  53. Python实现对脑电数据情绪分析
  54. Anaconda 5.2 method of installing Python Library (mysqldb)
  55. Python implements emotion analysis of EEG data
  56. Master some advanced usage of Python in 30 seconds, which makes others envy it
  57. python爬取百度图片并对图片做一系列处理
  58. Python crawls Baidu pictures and does a series of processing on them
  59. python链接mysql数据库
  60. Python link MySQL database