python learning (day1)

Acquaintance python

Founder python for Guido * Fanluosumu (Guido van Rossum). During Christmas 1989, he developed the script interpreter.

python is ⼀ what kind of language ⻔

python is an interpreted language, a weakly typed language.

Programming your language and get accustomed mainly from the following two ⻆ into ⾏ degree of classification, compiled and interpreted, static and dynamic your language and your language and strong class

Define your language and type and weak type definitions Language, we look at your language and compiled and interpreted language you want. Later Besides the strong and weak class type
type
What is the difference between compiled and interpreted?
The compiler is the source of every ⼀ statements are compiled into machine Language, and save it as ⼆ binary files, so when when running a computer
Directly to the machine to your language and when running a program, very fast;
When ⽽ interpreter is only in YES program, only ⼀ Articles of ⼀ your language and interpreted into machine to the computer to Perform, so when running a speed
After the compiler is not as good as when running a fast of.
This is because the computer can not directly recognize and YES we write the statement, it can only recognize your language and machine (a ⼆ hexadecimal format)
 
 
 
 

 

 

 

Compiled vs interpreted

Compiled
Pros: The compiler shoots as usual there will be pre-compiled code into ⾏ process optimization. Because the compiler only ⼀ times, you do not need when running a compiled when
Translation, so your language and compiled programs Perform efficiency ADVANCED. Your language and can be detached when running a separate environment.
Cons: After compiling If you need to modify the entire module needs to be recompiled. According compile time when running a corresponding environment ⽣
Into machine code between different operating system migration will be a problem, the need to compile the environment when running a different operating system
Perform files can.
Interpreted
Pros: Good platform compatibility in any environment when running a can, provided that the interpreter (Virtual Machine) installed.
Flexible and modify the code directly modify when you can, you can quickly deploy, will not be used down for maintenance.
Cons: every time when running a must explain ⼀ times, as compiled your language and performance.
 

1.2.python advantages and disadvantages

 
Look at the advantages
1. Python position is "elegant" and "clear", "simple", so Python always looks simple and easy to program
懂,初学者学Python,不但⼊⻔容易,⽽且将来深⼊下去,可以编写那些⾮常⾮常
复杂的程序。
2. 开发效率⾮常⾼,Python有⾮常强⼤的第三⽅库,基本上你想通过计算机实现任何
功能,Python官⽅库⾥都有相应的模块进⾏⽀持,直接下载调⽤后,在基础库的基
础上再进⾏开发,⼤⼤降低开发周期,避免重复造轮⼦。
3. ⾼级语⾔————当你⽤Python语⾔编写程序的时候,你⽆需考虑诸如如何管理你
的程序使⽤的内存⼀类的底层细节
4. 可移植性————由于它的开源本质,Python已经被移植在许多平台上(经过改动
使它能够⼯ 作在不同平台上)。如果你⼩⼼地避免使⽤依赖于系统的特性,那么你
的所有Python程序⽆需修改就⼏乎可以在市场上所有的系统平台上运⾏
5. 可扩展性————如果你需要你的⼀段关键代码运⾏得更快或者希望某些算法不公
开,你可以把你的部分程序⽤C或C++编写,然后在你的Python程序中使⽤它们。
6. 可嵌⼊性————你可以把Python嵌⼊你的C/C++程序,从⽽向你的程序⽤户提供
脚本功能。
再看缺点:1. 速度慢,Python 的运⾏速度相⽐C语⾔确实慢很多,跟JAVA相⽐也要慢⼀些,因此
这也是很多所谓的⼤⽜不屑于使⽤Python的主要原因,但其实这⾥所指的运⾏速度
慢在⼤多数情况下⽤户是⽆法直接感知到的,必须借助测试⼯具才能体现出来,⽐如
你⽤C运⼀个程序花了0.01s,⽤Python是0.1s,这样C语⾔直接⽐Python快了10倍,
算是⾮常夸张了,但是你是⽆法直接通过⾁眼感知的,因为⼀个正常⼈所能感知的时
间最⼩单位是0.15-0.4s左右,哈哈。其实在⼤多数情况下Python已经完全可以满
⾜你对程序速度的要求,除⾮你要写对速度要求极⾼的搜索引擎等,这种情况下,当
然还是建议你⽤C去实现的。
2. 代码不能加密,因为PYTHON是解释性语⾔,它的源码都是以名⽂形式存放的,不
过我不认为这算是⼀个缺点,如果你的项⽬要求源代码必须是加密的,那你⼀开始就
不应该⽤Python来去实现。
3. 线程不能利⽤多CPU问题,这是Python被⼈诟病最多的⼀个缺点,GIL即全局解释
器锁(Global Interpreter Lock),是计算机程序设计语⾔解释器⽤于同步线程的
⼯具,使得任何时刻仅有⼀个线程在执⾏,Python的线程是操作系统的原⽣线程。
在Linux上为pthread,在Windows上为Win thread,完全由操作系统调度线程的
执⾏。⼀个python解释器进程内有⼀条主线程,以及多条⽤户程序的执⾏线程。即
使在多核CPU平台上,由于GIL的存在,所以禁⽌多线程的并⾏执⾏。关于这个问题
的折衷解决⽅法,我们在以后线程和进程章节⾥再进⾏详细探讨。
 
 
 
 

 

Guess you like

Origin www.cnblogs.com/GYC-GXm/p/12059119.html