Python

    Python is a general-purpose high-level programming language. Its design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive. Its use of indentation as block delimiters is unusual among popular programming languages.

    Python supports multiple programming paradigms (primarily object oriented, imperative, and functional) and features a fully dynamic type system and automatic memory management, similar to Perl, Ruby, Scheme, and Tcl. Like other dynamic languages, Python is often used as a scripting language.

    The language has an open, community-based development model managed by the non-profit Python Software Foundation, which maintains the de facto standard definition of the language in CPython, the reference implementation.

History

    Python was conceived in the late 1980 by Guido van Rossum at CWI in the Netherlands as a successor to the ABC programming language (itself inspired by SETL) capable of exception handling and interfacing with the Amoeba operating system. Van Rossum is Python's principal author, and his continuing central role in deciding the direction of Python is reflected in the title given to him by the Python community, Benevolent Dictator for Life (BDFL).

    Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for Unicode. However, the most important change was to the development process itself, with a shift to a more transparent and community-backed process. Python 3.0, a major, backwards-incompatible release, was released on 3 December 2008 after a long period of testing. Many of its major features have been backported to the backwards-compatible Python 2.6.

Programming Philosophy

    Python is a multi-paradigm programming language. Rather than forcing programmers to adopt a particular style of programming, it permits several styles: object-oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by metaprogramming and by magic methods). Many other paradigms are supported using extensions, such as pyDBC and Contracts for Python which allow Design by Contract.

    Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution (late binding), which binds method and variable names during program execution.

    Rather than requiring all desired functionality to be built into the language's core, Python was designed to be highly extensible. New built-in modules can be easily written in C or C++. Python can also be used as an extension language for existing modules and applications that need a programmable interface. This design of a small core language with a large standard library and an easily extensible interpreter was intended by Van Rossum from the very start because of his frustrations with ABC (which espoused the opposite mindset).

    While offering choice in coding methodology, the Python philosophy rejects exuberant syntax, such as in Perl, in favor of a sparser, less-cluttered grammar. As with Perl, Python's developers expressly promote a particular "culture" or ideology based on what they want the language to be, favoring language forms they see as "beautiful", "explicit" and "simple". As Alex Martelli put it in his Python Cookbook (2nd ed., p.230): "To describe something as clever is NOT considered a compliment in the Python culture." Python's philosophy rejects the Perl "there is more than one way to do it" approach to language design in favor of "there should be one—and preferably only one—obvious way to do it".

    Python's developers eschew premature optimization, and moreover, reject patches to non-critical parts of CPython which would offer a marginal increase in speed at the cost of clarity. It is sometimes described as "slow". However, by the Pareto principle, most problems and sections of programs are not speed critical, and as computer hardware continues to become exponentially faster (Moore's Law), languages do have more hardware resources available. When speed is a problem, Python programmers tend to try to optimize bottlenecks by algorithm improvements or data structure changes, using a JIT compiler such as Psyco, rewriting the time-critical functions in "closer to the metal" languages such as C, or by translating Python code to C code using tools like Cython.

Usage

    Python is often used as a scripting language for web applications, e.g. via mod_python for the Apache web server. With Web Server Gateway Interface a standard API has been developed to facilitate these applications. Web application frameworks or application servers like web2py, Zope, and Django support developers in the design and maintenance of complex applications.

    Python has seen extensive use in the information security industry, including in exploit development. Python has been successfully embedded in a number of software products as a scripting language, including in finite element method software such as Abaqus, 3D animation packages such as Maya, Softimage XSI, and Blender, and 2D imaging programs like GIMP, Inkscape, Scribus, and Paint Shop Pro. ESRI is now promoting Python as the best choice for writing scripts in ArcGIS. It has even been used in several videogames.

    For many operating systems, Python is a standard component; it ships with most Linux distributions, with NetBSD, and OpenBSD, and with Mac OS X. Red Hat Linux and Fedora both use the pythonic Anaconda installer. Gentoo Linux uses Python in its package management system, Portage, and the standard tool to access it, emerge. Pardus uses it for administration and during system boot.

    Among the users of Python are YouTube  and the original BitTorrent client. Large organizations that make use of Python include Google, Yahoo!, CERN, NASA, and ITA. Most of the Sugar software for the One Laptop Per Child XO, now developed at Sugar Labs, is written in Python.

 

CPython

    The mainstream Python implementation, known as CPython, is written in C meeting the C89 standard. CPython compiles the Python program into intermediate bytecode,[43] which is then executed by the virtual machine. It is distributed with a large standard library written in a mixture of C and Python. CPython ships in versions for many platforms, including Microsoft Windows and most modern Unix-like systems. CPython was intended from almost its very conception to be cross-platform; its use and development on esoteric platforms such as Amoeba, alongside more conventional ones like Unix and Mac OS, has greatly helped in this regard.

     Stackless Python is a significant fork of CPython that implements microthreads; it does not use the C memory stack. CPython uses a GIL to allow only one thread to execute at a time while the Stackless Python threads are independent of the OS and can run concurrently. Stackless Python is better suited to scalable tasks and for use on microcontrollers or other limited resource platforms due to the thread's light weight. It can be expected to run on approximately the same platforms that CPython runs on.

    Google has started a project called Unladen Swallow in 2009 with the aims of increasing the speed of the python interpeter by 5 times and improving its multithreading ability to scale to thousands of cores.

 

 Alternative implementations

    Jython compiles the Python program into Java byte code, which can then be executed by every Java Virtual Machine implementation. This also enables the utilization of Java class library functions from the Python program. IronPython follows a similar approach in order to run Python programs on the .NET Common Language Runtime. PyPy is an experimental self-hosting implementation of Python, written in Python, that can output several types of bytecode, object code and intermediate languages. There also exist compilers to high-level object languages, with either unrestricted Python, a restricted subset of Python, or a language similar to Python as the source language. PyPy is of this type, compiling RPython to several languages; other examples include Pyjamas compiling to Javascript; Shed Skin compiling to C++; and Cython & Pyrex compiling to C.

    In 2005 Nokia released a Python interpreter for the Series 60 mobile phones called PyS60. It includes many of the modules from the CPython implementations and some additional modules for integration with the Symbian operating system. This project has been kept up to date to run on all variants of the S60 platform and there are several third party modules available. There is also a Python interpreter for Windows CE devices (including Pocket PC). It is called PythonCE. There are additional tools available for easy application and GUI development.

    ChinesePython (中蟒) is a Python programming language using Chinese language lexicon. Besides reserved words and variable names, most data type operations can be coded in Chinese as well.

Interpretational semantics

    Most Python implementations (including CPython, the primary implementation) can function as a command line interpreter, for which the user enters statements sequentially and receives the results immediately. In short, Python acts as a shell. While the semantics of the other modes of execution (bytecode compilation, or compilation to native code) preserve the sequential semantics, they offer a speed boost at the cost of interactivity, so they are usually only used outside of a command-line interaction (eg, when importing a module).

    Other shells add capabilities beyond those in the basic interpreter, including IDLE and IPython. While generally following the visual style of the Python shell, they implement features like auto-completion, retention of session state, and syntax highlighting.

    Some implementations can compile not only to bytecode, but can turn Python code into machine code. So far, this has only been done for restricted subsets of Python. PyPy takes this approach, naming its restricted compilable version of Python RPython.

    Psyco is a specialising just in time compiler that integrates with CPython and transforms bytecode to machine code at runtime. The produced code is specialised for certain data types and is faster than standard Python code. Psyco is compatible with all Python code, not only a subset.

 

 

Wiki Space: 
Open-source