20 Nov 2008 henrique   » (Journeyer)

cocos2d importing too slow?

So, you find cocos2d and think "man, I need to try it out!". Cool, so you went to your editor, open an usual "foo.py" and start typing some example...

import cocos
class HelloWorld(cocos.layer.Layer):
    def __init__(self):

followed by python foo.py; after some 2 minutes you got the result on the screen, but why is it too slow to start? The culprit is pyglet.

When cocos is imported, pyglet is imported as well. cocos will then try to append some resource directories to it and then the problem begins... pyglet will start indexing every file in the tree starting at ".", so if you are running this script at your home directory or inside a directory with a lot of files and directory (like a ~/dev directory as it is my case), it will add each file found in a dictionary.

The solution: Create a directory to put your code and run it there or wait for my bug report at code.google (out of time right now, but I will do it soon and let you know).

By the way, the homework is: what will happen if your game is at /usr/bin/my-ubergame and you start it in your home directory with, lets say, 15gb of mp3 and movies?

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!