Python source code compilation tips

Source: Internet
Author: User

The following describes in detail the Python source code programming skills and the spelling rules of Python source code. First, let's take a look at what is the Python language, the so-called Python: it is an object-oriented, literal translation computer programming language, and also a powerful and complete general-purpose language.

Before starting this part, I also want to talk about the state of a topic that we have been talking about and will continue to talk about in the future. We have been discussing this before. Save the user's status in a centralized place, especially in the case of large-scale cluster deployment. This is also true for django. It can be said that this golden rule is not just for a specific language.

A framework should be a high-level concept. So where can we put the status? Currently, some popular options are DB (memory table, or entity table), memcached, or cookie. However, these options are not interchangeable. For example, if there is a large amount of business data, it is not suitable to put it in the Python source code, because it may exceed the cookie size limit.

It is a pity that memcached (when using slab) also has its own restrictions. If the status data size span is large, data loss may occur, ahuaxuan encountered this situation long ago in the test environment. This is not the case because memcached is too open online. The internal reasons for this event have been described in another ahuaxuan article.

Put it on the DB, obviously, the pressure on the DB is also one of the issues we need to consider. Of course, in addition to these mainstream options, there are many other options, such as memcachedb, timesten, or others. However, when status data is important, we must thoroughly study and understand the storage technology of status data. Otherwise, we may encounter unexpected situations.

For example, a long time ago, I thought that memcached was LRU for a slab (and I also want to insert a note that LRU is not actually traversing the chunk linked list in slab, and only traverse the first 50 pieces of data. This is purely for speed ). Currently, there are basically two deployment policies for django. The first is to use mod_python to run django in the apache process, and the other is webserver + fastcgi.

The two methods have their own advantages and disadvantages. In the mod_python mode, our webserver must use apache, which has been the first in the webserver field for many years. Market share is also far greater than other webservers, but in recent years, several other webservers have emerged, among which ligttpd and nginx are well known.

They all pose a challenge to apache with high performance and low memory consumption, while mod_python is an apache plug-in. In this way, our webserver is limited to apache, however, apache + mod_python is also a very stable solution. The second type is webserver + fastcgi, which can be selected at will. Most webservers provide support for fastcgi.

For example, we are familiar with lighttpd and nginx, and it is said that in many cases, FastCGI can provide better security and performance than mod_python. FastCGI is more lightweight than Apache for small websites. It is said that qq's personal space is implemented by c ++ and fastcgi. Oh, where is the advantage of this? The processing speed of c ++ will be very fast.

That is to say, each fastcgi process a request very quickly. For example, it takes 50 milliseconds to use python. c ++ may only need 20 milliseconds to process this request. This example may not be accurate, to illustrate the features of fastcgi ). Although c ++ is a little more troublesome in development, in terms of performance, c ++ must be no1. From this example, we can see that, the speed of fastcgi depends on the speed at which a request is processed ).

Tkinter is a Python source code for Tk interfaces. The Tkinter Library provides interfaces for Tk APIs, which belong to the GUI tool group of Tcl/Tk. Tcl/Tk is a writing and graphics device developed by John Ousterhout. Tcl (tool command language) is a macro language.

It is used to simplify the development of complex programs in shell. The Tk Toolkit is developed with Tcl to simplify the design process of user interfaces. The Tk toolkit consists of many different widgets, such as a button and a scroll bar. With these widgets provided by Tk, we can quickly develop the GUI. Perl, Scheme, and other languages also use the Tk library for GUI development. Tkinter is cross-platform and can be used on various platforms.

Python Imaging Library (PIL) ---- Python source code provides powerful graphic processing capabilities and supports a wide range of graphic file formats. This Library can convert, print, and display graphic formats. It can also process some graphic effects, such as Zoom-in, zoom-out, and rotation. It is a powerful tool for Python users to perform image processing.

Pmw (Python megawidgets) Python super GUI component set-an advanced GUI component built using the Tkinter module in python. Each Pmw combines one or more Tkinter components, to achieve more useful and complex functions.

  1. Python source code compilation skills
  2. Simple and Easy-to-use Python tools
  3. Introduction to the Python application field
  4. Python Android Object-Oriented Programming-Python applications
  5. How to Use the Python module to parse the configuration file?

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.