title: Is there a faster way to blit many images on Pygame?
body: <p>I have a "map" / track:</p>
  
  <pre><code>track_data = [
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1],
      [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1],
      [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1],
      [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
  ]
  </code></pre>
  
  <p>Each of these numbers represent an image. As you'll see on the class, I blit each one of them at each loop. If I blit them only once and don't fill the background to increase performance, the moving objects (The cars) paint the screen in a brush-like fashion (Obviously). So, I have to draw them at each frame. The thing is: It's too damn slow. Is there a faster way to blit them?</p>
  
  <pre><code>class Track:
  
      TRACK_SIZE = 16
  
      START = 0
      DIRT = 1
      ROAD = 2
  
      DIRT_IMAGE = "gfx/dirt.png"
      ROAD_IMAGE = "gfx/road.png"
  
      def __init__(self):
          self.data = test.track_data
          self.spawnpoints = test.track_spawnpoints
          self.waypoints = test.track_waypoints
          self.actors = []
          self.spawn_positions = {}
          self.actor_dimensions = [
              options["RESOLUTION"][0] / 16,
              options["RESOLUTION"][1] / 16
          ]
          self.updated = False
          for row in self.data:
              actor_row = []
              for column in row:
                  if column == Track.START:
                      pass
                  elif column == Track.DIRT:
                      actor_row.append(pygame.image.load(Track.DIRT_IMAGE))
                  elif column == Track.ROAD:
                      actor_row.append(pygame.image.load(Track.ROAD_IMAGE))
              self.actors.append(actor_row)
          occurence_counter = 0
          for y in range(Track.TRACK_SIZE):
              for x in range(Track.TRACK_SIZE):
                  if self.spawnpoints[y][x] != 0:
                      self.spawn_positions[occurence_counter] = (
                          x*int(self.actor_dimensions[0]) + Car.WIDTH,
                          y*int(self.actor_dimensions[1]) + Car.HEIGHT
                      )
                      occurence_counter += 1
  
      def draw(self, surface):
          if not self.updated:
              for y in range(Track.TRACK_SIZE):
                  for x in range(Track.TRACK_SIZE):
                      surface.blit(
                          self.actors[y][x], 
                          [x*int(self.actor_dimensions[0]), y*int(self.actor_dimensions[1])]
                      ) # Here &lt;&lt;&lt;
  </code></pre>