kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Patch: Minor event loop optimization #751

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The event loop(s) in app/base.py does method-lookup for every loop iteration, 
something which is a known Python time sink for often-called methods. The 
attached patch assigns idle(), step() and send() to local variables before 
entering the loop. 

Using local variables rather than method lookup leads to about 30% speedup per 
loop iteration. Of course, the total effect on a real program is miniscule (by 
far the most time is spend in code called by the loop after all). But it's a 
simple "optimization" that don't really affect the readability of the code and 
has no other negative downsides, so ... 

Original issue reported on code.google.com by griatch on 13 Jun 2014 at 12:36

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 14 Jun 2014 at 9:42