The Python language is not known to most people. Here is a brief introduction to the Python language. By the way, let's talk about the Python standard library. As the saying goes, libraries are languages and languages are libraries. It can be seen that it is important to have a set of high-quality and well-reusable libraries for a general development language. It's no wonder that "C ++ daddy" BjarneStroustrup? Everyone is suffering: there are still too few libraries for C ++, and the c ++ community needs to develop more high-quality libraries!
Fortunately, developing a set of high-quality libraries for the Python language is far less complex than C ++. The Python community also knows the importance of libraries. The result is that the Python release contains more than 300 standard libraries. This does not include more than 50 Libraries dedicated to Mac machines. Who makes that kid an alternative ). Most of the more than 300 databases have cross-platform capabilities * NIX/Windows ). These libraries cover all aspects of development. Python users can use a typical command line environment, such as Linux Shell, to complete most of the work simply using the standard library, at the same time, you do not need to consider compatibility issues of the database. The attention of the Python community to libraries is evident.
Even with so many standard libraries. This does not seem to prevent developers in the Python community from thinking like nothing. With the help of the concise, elegant, and flexible expression ability of dynamic languages, these third-party libraries often present amazing imaginations.
Well, now let's pick up a bit in the huge Python library, maybe it can bring us some alternative ideas.
- Instructions on how to design the Python language
- Object-oriented language-Python
- Introduction to the standard Python language
- Exploring simple and powerful Python language
- In-depth analysis of the mysteries of the Python language
SQLObject
SQLObject can be seen as Hibernate in the Python field. It is also the most mature and convenient O/R mapping tool in the python community. Compared with Hibernate, SQLObject utilizes the unique features of dynamic languages to flexibly use inheritance and MetaData? Ability to quickly and easily define the ing Class in the program. You do not need to define an XML file as in Hibernate. Similarly, with powerful dynamic capabilities, SQLObject also has a function far beyond Hibernate, that is, the ing Class of SQLObject can dynamically change its own structure at runtime, this also means that the table structure in the database can be changed at runtime. In short, developers who know little about Hibernate can quickly understand SQLObject. Although I have always thought that SQLObject is far from making full use of Python's dynamic capabilities. However, this is a good start. Maybe we can see more new O/R mapping tools in the near future.
TurboGear?
Since the fame of RoR (Ruby on Rails) in the Web development field overnight, the follow-up work has sprung up in other language communities. Although TurboGear? Instead of deliberately imitating RoR, it does get more attention from the RoR fashion. Same as RoR, TurboGear? It is also a lightweight Web development kit that uses several command line tools to quickly generate basic framework code with the database as the core. Typical RoR ideas! This is the same as the principle of many open-source frameworks-"avoiding re-inventing the wheel ". TurboGear? Web control layer using CherryPy ?; The persistence layer uses SQLObject; the template uses Kid; AJAX uses MochiKit ?. Almost all important functional components are sourced from third parties. TurboGear? Itself is more like a binder, combining all functions together, and forming a doubling of power.
4 Suite
Although the Python Standard Library provides XML processing tools, it only provides some basic functions. If you want to obtain more powerful XML processing capabilities, 4Suite is a better choice.
4 suite is called "expert selection" in XML tools ". In addition to the most basic Dom-Like and SAX-Like processing libraries, the 4 Suite also provides XInclude, XPointer, XLink, XPath, and XUpdate for XML document query and update operations; provides complete XSLT processing capabilities.
4 suite is not only powerful, but also has good performance. This is mainly due to the use of C in its core code. This is the perfect choice for 4Suite, where a large number of XML documents need to be processed.
Pyro
Pyro stands for "Python Remote Objects ". Literally, you can understand the functions of Pyro: provides remote objects. Pyro provides a concise RPC solution for the Python language. In fact, there are some more common Remote Call solutions in the Python language, such as XMLRPC and SOAP based on XML. So what are the advantages of a simple Python Remote Call solution like Pyro? That is, performance and ease of use.
Because dynamic languages have powerful reflection capabilities, Object serialization is easy for Python. Object serialization is called pickle in Python, which is the core mechanism of many Python applications. Pyro also makes full use of the power of pickle to provide remote object calls between networks. Its performance far exceeds the encoding/Decoding of remote objects using XML. At the same time, it is also very concise in the interface call design. On the server and client, only two or three lines of code are required to encapsulate and call objects, which is far simpler than SOAP.
Twisted
Last month, Zope 3.2 was released. In the latest version, an important change was that the network framework code used for processing Web requests for nearly ten years was abandoned, instead, the code is implemented with Twisted as the core. It is said that this can improve system performance and scalability. So the Twisted library once again became the focus of attention. The core concept of Twisted is non-blocking Asynchronous Network server, so it is also used as an ACE in Python. If you do not know what ACE is, read the previous article on the C ++ library ), this is the best network processing model so far. Maybe it is caused by the inherent complexity of non-blocking asynchronous processing. Twisted is almost the most complex and difficult to use Python library I have ever seen. Twisted users need to face a large number of new concepts and new models, which is somewhat similar to ACE. The steep learning curve hinders many people from mastering the Twisted library. This may be a necessary price for high performance. It's no wonder that o'relli cited a nine-headed strange snake on the cover of his book about Twisted.
Psyco
What are the disadvantages of praising Python? Is it performance. Performance-it has become a deep-rooted problem with Python. Do not compare it with a language like C ++/Java/C #, even if it is a scripting language like Ruby, Perl, and PHP, python's performance is still the worst. The designers of Python seem to only care about the perfection of the Language Mechanism and almost ignore the performance. The CPythony engine has been developed for so many years. There are few performance optimization codes to view its source code. The object reference model is still using the reference counter method. As for developing a JIT engine, forget it. Fortunately, the appearance of Psyco gave us a glimmer of hope. Psyco significantly improves the performance of the entire application by compiling the running bytecode into binary code. In some environments, Psyco can even increase the speed by an order of magnitude. Although Psyco cannot be regarded as a JIT engine in the true sense, it cannot provide completely transparent services like JIT in Java. But we still want to be excited for the development of Psyco. Currently, in the latest version, you only need to add two lines of code to make your program fully use Psyco, thus improving performance.
WxPython
In the eyes of many people, the dynamic language/scripting language is generally only suitable for the work of command line or WEB, and it is really ugly in desktop development. The emergence of wxPython is undoubtedly a strong response to this prejudice.
The C ++ framework wxWindow, which has been developed for many years, is now renamed as the Python package of wxWidgets. WxWindow aims to build a cross-platform GUI framework. WxWindow is now running well on Windows/Unix/Mac. Naturally, wxPython can also span the above platforms.
The native window used by wxPython. This means that the GUI developed using wxPython is no different from the local GUI system of the operating system in terms of the interface appearance. If we compare it with the GUI library in Java, we can find that wxPython is more similar to SWT rather than Swing. Because SWT is also used as a native window, think about the advantages of the native window when the Eclipse interface is beautiful.
Although many C ++ enthusiasts are quite vocal about wxWindow framework design, after Python encapsulation, there is no pointer or event mechanism in the MFC era, the ease of use of the wx framework has been greatly improved. This is another great charm of Python. The above describes the Python language.