title: Poor Pyglet Performance
body: <p>I am thinking about porting a project over from PySFML to Pyglet. SFML is a bit of a wonky library, and even though it runs decently enough, I thought I would take a look at Pyglet. Unfortunately, Pyglet displays erratic FPS changes when doing simple things (between 20 and 800 FPS), and barely manages to draw frames when I try to do anything fancier.</p>
  
  <pre><code>import pyglet
  
  window = pyglet.window.Window()
  fps_display = pyglet.clock.ClockDisplay()
  labelList = []
  for i in range(100):
      label = pyglet.text.Label('Hello, world',
          font_name='Times New Roman',
          font_size=36,
          x=window.width//2, y=window.height//2+i,
          anchor_x='center', anchor_y='center')
      labelList.append(label)
  
  
  def main():
      pyglet.clock.schedule_interval(update, 1/30.0)
      pyglet.app.run()
  
  def update(dt):
      for la in labelList:
          la.x += 1
  
  @window.event
  def on_draw():
      window.clear()
      for la in labelList:
          la.draw()
      fps_display.draw()
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>The example is goofy, but I'm just taking 100 labels and moving them across the screen. This runs at about 7 fps on my machine. Using SFML, drawing 500 sprites and handling input gives me 200ish FPS.</p>