Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you were planning to write a high performance game using python, most likely you wouldn't be using the vanilla cpython interpreter, but instead using cython (http://cython.org/) to write extensions in essentially C for all your high performance code.

I think it's important to remember one of the core tenants of python is to first write in python, then optimize the bits where necessary in C by moving those calls into an extension - by using cython you get to move to C like speeds by just annotating your existing python code.

Also - I think a fairly more common approach to using python in game development is to write the core in C++, then call out to python for scriptability purposes (e.g. configuring characters/levels) - rarely would one write a full game in python unless extensions were heavily used, for the reasons quoted above.



I agree with everything you say but continually find cases where things have to be rewritten in Cython / using the CPython C-api or moving core logic to numpy. Knowing that you cant be interactive if your solution requires

a) allocating more than 160k objects

b) creating more than 22k numpy arrays

c) entering a with context more than 3700 times

d) doing a single for loop of over a million elements

can save you time from the get go. I am not suggesting that you cant write fast interactive code in Python, I am saying you wont write fast code by accident.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: