Python Learning---------Day1

Source: Internet
Author: User

Chapter One question and answer session
A Why do people use Python
Software Quality
Developers ' efficiency
Portability of programs
Support for standard libraries
Component integration
Enjoy the fun
Two Disadvantages of Python
The only downside to Python is that Python does not execute as fast as a compiled language like C + +
The standard way to implement Python is to compile (or convert) the statement of the source code in the form of a byte code, after which
Then the bytecode is interpreted, because bytecode is a platform-independent format, bytecode has portability. Then, because
For Python to not compile the code into the underlying binary code, some Python programs will be more than a full compiler like C
Speak slowly.
Three What to do with Python
System programming
User Graphics interface
Internet scripts
Database programming
Rapid prototyping
Numerical computation and scientific computational programming
Games, images, artificial intelligence, XML, robotics, etc.
Four What are the technical advantages of Python?
Object oriented
Free
Portable
Powerful features
Dynamic type

    • Automatic memory management
    • Large program Support
    • Built-in object types
    • Built-in Tools
    • Library Tools
    • Third-party tools

can be mixed
Easy to use

Chapter II How Python runs the program
A Introduction to the Python interpreter
An interpreter is a program that lets other programs run, and in fact, the interpreter is the computer hardware of the code and the machine
The software logic layer between
When Python is installed on the machine, it contains some of the minimized components: an interpreter and a supported library, based on
Depending on the usage, the Python interpreter may take the form of an executable program, or as a link to another program
A series of libraries. Whatever form you take, the Python code you write must run in the interpreter.
Two Python's procedural perspective
When the program executes, the inside of Python (which is completely hidden from most users) will first source code (the language in the file
Compiled into so-called bytecode, compilation is a simple translation step, and the bytecode is the bottom of the source code,
Platform-independent representation. Once the program is compiled into bytecode, the subsequent bytecode is sent to a virtual python called
On the computer (PVM).
Three Three ways to implement Python
CPython
Jython
IronPython
Four Execution Optimization Tool
Psyco Real-time compiler: A component that expands bytecode execution modules, allowing programs to run faster. Psyco
is a PVM enhancement tool, this tool phone and use information, when the program runs, can be part of the program's bytes
Code into the underlying real binary machine codes, enabling faster execution, in the development process, Psyco
This conversion can be done without code modification or a separate compilation step, with the biggest drawback being that Intel x86
The architecture of the chip generates machine code.
Shedskin C + + converter: is an engine system that uses a different Python program execution method that will py
The Thon code goes to C + + code, and then compiles the resulting C + + code into machine code using the C + + compiler.
Freeze binary: It is able to program the bytecode, interpreter and any program required by the Python support text
Pieces bundled together to form a separate package. The process will be somewhat different, but the actual result will be a separate
Binary executable.

Chapter III How to run a program
A Writing code in interactive mode
Two System command line and file
Three Using the command line and files
Using Print statements in a file
Four Unix executable script (#!)
UNIX Env Find Tips
The #!/usr/bin/env Python env program can locate the Python interpreter by setting the system's search path.
This approach makes the code more portable
Five Import and overloading of modules
Each python source code file that ends with the extension name. PY is a module
Import imports, only one file can be imported at a time, import is a very expensive operation so that each program does not run
Can repeat more than once
Reload overload, the return value of the reload function is a Python object
Six Using the Idle
Seven Embedded Calls

Python Learning---------Day1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.