Advantages of Python scripts

Source: Internet
Author: User

The following is an article about Python scripts. Similarly, there are differences between different languages. The language is just a tool. You need to select different tools based on different tasks and use Prolog as an expert system, C is used for interaction with the underlying operating system, and Java or Python is used for cross-platform communication.

Generally, it is easier to learn the scripting language than the system programming language, because the system language such as C/C ++/Java has more powerful functions, high language complexity, and long learning cycle; in a sense, a script language command can do more.

More humane, reflecting the purpose of serving machines. Because if a program is less done by people, the machine will do more, just in line with the idea of automation. The machine is invented to reduce human labor. From this perspective, the scripting language is worthy of strong respect.

However, nothing is perfect. The cost of making a machine too much is likely to be less efficient than making it run less. For example, to perform a dynamic type check during Python running, it takes time for the machine to run. In static compilation languages such as C, this job is left for people to do. There are some similar factors, therefore, C is much more efficient than Python scripts.

Garbage collection (GC) in the current version, the reference counting garbage collection and the optional cyclic structure garbage space scanning technology are used, once the object becomes inaccessible, it will be recycled, but it cannot be guaranteed to recycle the memory garbage that contains the cyclic reference count. The reference counting algorithm is more intuitive: records the number of pointers to each bucket, and updates the reference counting when performing some operations on the bucket.

When a bucket is allocated, the reference count is initialized to 1. As long as the bucket reference is copied, the reference count is incremented by 1. When the bucket reference is deleted, the reference count is reduced by 1, if the reference count is reduced to 0, the storage slice will be recycled due to inaccessibility.

Obviously, the counting algorithm cannot recycle the circular data structure. Imagine a simple scenario: a member of object a points to object B, and B also points to. In addition, the Code only references part a. object B is generated only by the aid of object a. If object a is deleted later, both object a and object B become memory garbage.

Theoretically, it should be deleted by the memory manager. However, since the reference counting algorithm only examines one node at a time, the cyclic data structure cannot be recycled. Therefore, we should try to avoid loop references during programming. The execution efficiency of Python is slightly inferior to that of C/C ++/Java, but the code length is greatly shortened. In addition, Python supports a wide range of platforms, libraries, simple syntax, and fast development.

Therefore, Python is often used to build a large program instead of C/Java. You can use C/C ++ to implement the system efficiency. In addition, Python can also be used as the glue language), because Python can communicate well with C and Java.

. Python implemented on the NET platform; specifically, Python. NET is a compiler and runtime. It compiles Python scripts into external Virtual Machine formats and.. NET class library is available in Python. Python on the IronPython. NET platform; compared with the traditional Python, IronPython supports optional static compilation functions, and the IronPython program that has been statically compiled forms a conventional one.

. NET executable file. EXE file ). IronPython can even be statically compiled into. NET Dynamic Link Library. dll files) and called by C #, VB. NET, and other. NET languages. The excellent features of Python determine its extensiveness in practical application. Rapid Prototyping; web server scripts; scientific computing; document processing; database programming;

Embedded Development; GUI development; game development; mobile development ...... python scripts are supported by the powerful Python community, a wide range of class libraries, and C/C ++/Java and other languages to provide extensible modules. Moore's law asserted that processor, memory, or I/O devices will no longer significantly affect the execution efficiency of programs. For a considerable number of applications, the same function is implemented.

Compared with the script language, the system language may be more efficient than the script language, but the script language code may be much lower than Python and Java at about ). The development cycle is shorter, and many common functions have been implemented in the system language. It can be used as a function module and can be used with the glue function of the script language to implement the system.

  1. How to embed Python into C ++ applications?
  2. In-depth discussion of Ruby and Python syntax comparison
  3. Introduction to Python
  4. Python Learning Experience: version, IDE selection and coding Solutions
  5. Analysis of Python GIL and thread security

Related Article

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.