Python
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. Python is an interpreted language. The interpreter is open-source. A good range of libraries exist.
[edit] About PythonPython has become a powerful tool for game development. It has been used extensively in commercial games, including Freedom Force, EVE Online, Civilization IV, Toontown Online, Pirates of the Caribbean Online, Temple of Elemental Evil, and Battlefield 2 (as well as 2142). Python's primary advantage is that it is very fast to develop in. Writing python code typically takes a fraction of the time that it takes to write the equivalent C code. It has been estimated that it is 5 to 10 times faster to write a program in Python than C. This can cut months or years off of a project's development time. There is also a significant body of library code that handles 2D and 3D graphics rendering. Python's primary disadvantage is that it is generally not fast enough for complex calculations (like 3D physics). Most complex games that use python offload a few subroutines to C, on an as-needed basis, or use an existing C library (like ODE for physics). Most developers that try this mix swear by it: the result is a game that can be developed at the speed of python, but which runs at the speed of C wherever it is necessary to do so. When mixing python with C, the impact on speed depends on how much of the time is spent executing Python logic versus how much of the time is spent in C libraries. The Python logic can be 10-100 times slower than C. It is recommended that the critical code (matrix calculations, for-each-pixel manipulations, 3D graphics, etc) be in C libraries. Python makes it easy to interface with C; Boost Python makes it easy to interface with C++. It is also possible to use Pyrex, a C/Python hybrid language that makes it particularly easy to integrate with C libraries, and also makes it possible to write C-speed code in a Python-like language. In addition SWIG easily allows a developer to wrap C/C++ functions for use with many scripting languages including Python. Python is generally considered a fairly easy language to learn. If you already have a C/C++ background, you will find its features familiar: you will only have to spend an hour in the Python.org tutorials to be able to use it. Python's feature set includes powerful list and string manipulation, tables, sets, and a sizeable library of utility functions such as serialization, XML parsing, networking, regular expressions, and so forth. Matrix and vector manipulation are included with Numeric Python. Very high-quality 3D graphics libraries are also available. As a rule, all of these libraries are written in and operate at the speed of C. A key advantage of Python is that it is relatively easy for non-programmers to read. This makes it suitable as a scripting language. For example in an RPG you might build the main part of the game in C++ but write scripts (where the shopkeepers go at night, what the NPCs say, how the trolls walk back and forth) in Python. In conclusion, this language is very useful as long as you don't ask it to do what it does worst (calculation on large data sets): such tasks should be offloaded to C. There exists a tool, Psyco, which gives your program a boost without needing any rewrite. All you have to do is import it at the beginning of your code. The main drawback is that Psyco only runs on x86-compatible platforms at the moment. If you plan using Python for game development you might also want to consider looking at Ruby although you will find Python is faster (All Languages Compared, Python vs Ruby). Both languages have their up- and downsides, so choose wisely. [edit] Tutorials and Source[edit] Library Dependent[edit] Generic game programming libraries
[edit] 3D libraries
[edit] External Links
|


