Image processing commands are expensive. Best to precalculate all the rotations.
Also, since it's probably regular CPython you're running, there's only ever one thread running at a time. If you're using threads, you're probably doing something wrong. On Wed, Jan 20, 2010 at 5:08 PM, Bram Cymet <bcy...@cbnco.com> wrote: > Hi All, > > I did some profiling of my pygame application and I found that it was > spending a lot of time doing rotation operations. Basically I have some > balls on the screen that are represented by gifs with transparent > backgrounds and I want to make them spin. > > I use the following code: > > > These first two lines are only run in init for the object > self.image = pygame.image.load('image.gif') > self.image = self.image.convert() > > self.image = pygame.transform.rotate(self.image, degrees) > self.rect = self.image.get_rect() > > Then I return the rect and blit and update that part of the screen. A > lot of time is spent on that pygame.transform.rotate command. On my > laptop with a dual core 2.2 ghz processor if works fine. However on the > target hardware which is: > > Atom 330 (dual core 1.6 ghz) with an ION chipset and graphics > > it runs very slow and can take up to 0.2 seconds to execute just that > one line of code. > > Is there something I am doing wrong? Is there some way I can make this > faster. > > I am not sure if it matters but just for the sake of completeness: the > application is multi-threaded but only one thread is running during this > part of the application. > > Any help would be great. > > Thanks, > > -- > Bram Cymet > Software Developer > Canadian Bank Note Co. Ltd. > Cell: 613-608-9752 > > >