What does Python offer?

Delaney, Timothy tdelaney at avaya.com
Wed May 29 19:05:24 EDT 2002


> From: Solosnake
> 
> > > Why would it be useful to a games programmer?
> >
> > Obviously. Blade of Darkness uses it ...
> 
> Hmmm. Answering a 'why' question' with 'Obviously' isn't very 
> useful or
> informative.

Oops - my apologies. I read that as "Would it be useful ..." ... which
seemed kinda strange to me, hence the "obviously" reply. Mind playing silly
buggers ...

> I was really enquiring about how python might differ from 
> other langauges,
> and how this might be pertinant to games programming. e.g. I 
> believe it is
> an interpreted langugae, as opposed to compiled? So AI code written in
> Python could be modified by end users? This cannot be done 

Yes indeed - in fact, this is very easy.

> I do not wish to invest any time in learning python if it is 
> of no special
> use, and everything I could do could be done with C++ anyway. 

1. Learning enough Python for even fairly complex tasks takes about a week.

2. Learning Python + Python wrappers to gaming libraries (e.g. PyGame ->
SDL, PyOpenGL -> OpenGL) is almost certainly going to be faster than
learning the C++ API for just the libraries.

> How does/can
> Python be integrated with other languages e.g. C++? I've read this :
> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq05.007.htp
> but its scant knowledge to start with.

As I said, you need to read up about extending and embedding Python. In
particular, look at Boost (also look at SWIG, but for C++ Boost is almost
certainly what you want).

> > http://www.python.org/doc/Newbies.html
> I've looked at these, but they are mostly 'Hello World' for 
> python newbies.

Well, you *are* a Python newbie aren't you?

> > http://www.python.org/doc/current/tut/tut.html
> Again, a tutorial on the language, as opposed to details about the
> language's features.

The second URL I game is to all the Python docs - including the language
ref. However, as with any language, until you have a basic understanding of
the language (both syntax and semantics) the lang ref isn't going to be much
good for you.

> > http://www.pygame.org/
> > http://pyopengl.sourceforge.net/
> 
> I don't want to write my games in python, unless it runs faster then
> C/C++/assembly? :)

It may or it may not. Python allows you to concentrate on the algorithms
involved, rather than the nitty-gritty. These are thin wrappers to optimised
libraries written in lower-level languages. Any time spent inside these
libraries is working at the same speed as if you accessed the libraries via
a C++ API.

Was the performance of Blade of Severance sufficient for you? As I
understand it, it used these exact same techniques - game logic written in
Python, accessing graphics routines (and probably other bits too) written in
another language.

Python is almost unique in its ability to easily be extended using other
languages (esp. C/C++) and to be embedded in programs written in other
languages.

If you don't write in Python, it's no skin off our noses - but I strongly
suggest that you spend the short amount of time required to see if it will
meet your needs. At the very least, prototype your games in Python - it
usually takes less time to prototype in Python, the recode in another
language, than to do it all in the other language to begin with. And you may
just find that there is no need to take the extra recoding step.

Tim Delaney





More information about the Python-list mailing list