[Twisted-Python] Two main loops

Nitro nitro at dr-code.org
Sun Nov 11 19:05:30 EST 2007

In a game you usually never send/receive huge objects. For various reasons  
you always try to reduce your bandwidth as much as possible. A low  
bandwidth implies a rather low number of objects and data.
That being said I am using pb for transferring state changes which should  
be guarenteed to arrive (for example a command to load a new game world)  
and using a custom pb-like method based on udp and which uses  
messaging/packaging for things which do not have to be transmitted on a  
guarenteed basis. An example for the latter is updates of the position of  
world objects for instance. If a udp packet is lost, I don't really care  
because a new one will be send very soon anyways.
I am able to render (client) / simulate (server) with more than 200 fps  
this way. So while python might be slow compared to C++ this proves that  
it's actually possible to write python code which performs fast enough. It  
also proves that it's more important to optimize your algorithms and not  
your code. In the case of a game this means to think about ways to reduce  
the data that needs to be transmitted instead of making the  
serialization/network code faster.


Am 11.11.2007, 22:06 Uhr, schrieb Jasper <jasper at peak.org>:

> That depends.  When I send moderately sized objects over Twisted, this  
> approach causes my frame rate to stop while Twisted is busy, and worse  
> makes my GUI non-interactive.  For a game, this is generally  
> unacceptable...
> I'm not sure of a good/nice way to deal with this.  Slicing  
> transmissions into a sequence of smaller chunks seems like a fair pain  
> in the ass, but then again the alternatives are punting to another  
> thread/process. :-/
> -Jasper

More information about the Twisted-Python mailing list