[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame's future beyond 1.8



Marcus von Appen wrote:

On, Mon Aug 21, 2006, Alex Holkner wrote:

[...]



In the more general case, the small amount of Python wrapper that exists on every Pygame-ctypes function will indeed make it perform slower than its Pygame counterpart. I would argue that if this small performance penalty is significant for a particular project, then that project is not really suited to be implemented in Python.



If a small penalty of e.g. 0.5ms in a function exists and this function
is called 50 times in your project code you'll have a total penalty of
2.5 ms already. Now let's assume, this function is (or must be) called
periodically...
If the author now mourns about that, are you going to tell him, that
his projects is not suited to be implemented in Python?


Of course your argument can be applied to any arbitrary-sized problem, but I thought I would clarify the figures. The overhead of Pygame-ctypes that is directly a result of using ctypes (see below) is 0.22 microseconds---several orders of magnitude less than your example. For comparison, the cost of a single addition is 0.07 microseconds.

Tests conducted on AMD64 3500, GCC 3.4.3, Linux 2.6.14, Python 2.5 beta 3 (64-bit), Pygame-ctypes r938, Pygame r938, SDL 1.2.11.

Pygame:
python2.5 -OO -m timeit -s 'import pygame; pygame.init()' 'pygame.time.get_ticks()'
1000000 loops, best of 3: 0.47 usec per loop


SDL-ctypes:
python2.5 -OO -m timeit -s 'import SDL; SDL.SDL_Init(SDL.SDL_INIT_TIMER)' 'SDL.SDL_GetTicks()'
1000000 loops, best of 3: 0.694 usec per loop


Pygame-ctypes: (performs additional checking)
python2.5 -OO -m timeit -s 'import pygame; pygame.init()' 'pygame.time.get_ticks()'
100000 loops, best of 3: 2.3 usec per loop


Simple addition only:
python2.5 -OO -m timeit '1+1'
10000000 loops, best of 3: 0.0714 usec per loop

Saying things like that basically means, that you do not understand the
pitfalls of software dependencies and how to deal with them.


Alex.