Python Roundtable Friday One person ported Python to the PS2, another to the GameCube Memory Management ----------------- Python allocates many tiny blocks Cache issues important on consoles Be very careful about fragmentation Python has many different memory hooks -- check ceval2.c for allocations that happen all the time, eg. 2 allocs for each method call Stackless Python can do lightweight threads (one person had 20,000 threads) Where is the runtime only version of Python py-embed? There's Pippy - Palm Python that's <= 256k with interpreter Freeze takes bytecode and makes it statically loaded - can avoid module loading entirely. Psyco is a JIT for Python Pyrex uses Python runtime but can be compiled if you give variable declarations (with a new syntax) "numeric" (used to be "numpy") is efficient on large vectors/matrices Use map, apply, intrinsic data structures, otherwise up to 1000x slower on directly translated code Avoid SWIG: bad for C++ (ok for C but slow/bloated), does a malloc for every call PyOpenGL would be fast except for SWIG Boost::Python problem is templates kill the compiler (GCC) on console Just use Python's C API, avoid wrappers One (nice) interface had about 50 3D engine+UI game engine entry points + like 2 for networking. Others used SWIG and were huge. There was 1 artist who was willing to write Python code Design a very tight interface, otherwise designers writing Python code will cause trouble Error checking is a bit annoying on a console where you have high turn-around. Make a PC debugging client that connects to console's Python interpreter: inspect variables, reload scripts, etc. Script development environment to improve productivity Use PyUnit unit testing framework; replace compile button with unit test button. Much easier to write unit tests in Python than C++. Also console's C++ compilers suck (no/bad exception handling). PyChecker - good for static checking, get the add-on Designers want to iterate! Can quickly determine what is fun. Involve designers in interface(API) design Pair program scripts with a designer and a programmer Build an automated build script in Python Someone's AI editor is in Python "BuildBot" -- watches version control and rebuilds "Scons" -- "make" replacement "distutils" -- makes a Windows installer