title: My python program is running really slow
body: <p>I'm making a program that (at least right now) retrives stream information from TwitchTV (streaming platform). This program is to self educate myself but when i run it, it's taking 2 minutes to print just the name of the streamer.</p>
  
  <p>I'm using Python 2.7.3 64bit on Windows7 if that is important in anyway.</p>
  
  <p>classes.py:</p>
  
  <pre><code>#imports:
  import urllib
  import re
  
  #classes:
  class Streamer:
  
      #constructor:
      def __init__(self, name, mode, link):
          self.name = name
          self.mode = mode
          self.link = link
  
  class Information:
  
      #constructor:
      def __init__(self, TWITCH_STREAMS, GAME, STREAMER_INFO):
          self.TWITCH_STREAMS = TWITCH_STREAMS
          self.GAME = GAME
          self.STREAMER_INFO = STREAMER_INFO
  
      def get_game_streamer_names(self):
          "Connects to Twitch.TV API, extracts and returns all streams for a spesific game."
  
          #start connection
          self.con = urllib2.urlopen(self.TWITCH_STREAMS + self.GAME)
          self.info = self.con.read()
          self.con.close()
  
          #regular expressions to get all the stream names
          self.info = re.sub(r'"teams":\[\{.+?"\}\]', '', self.info) #remove all team names (they have the same name: parameter as streamer names)
          self.streamers_names = re.findall('"name":"(.+?)"', self.info) #looks for the name of each streamer in the pile of info
  
  
          #run in a for to reduce all "live_user_NAME" values
          for name in self.streamers_names:
              if name.startswith("live_user_"):
                  self.streamers_names.remove(name)
  
          #end method
          return self.streamers_names
  
      def get_streamer_mode(self, name):
          "Returns a streamers mode (on/off)"
  
          #start connection
          self.con = urllib2.urlopen(self.STREAMER_INFO + name)
          self.info = self.con.read()
          self.con.close()
  
      #check if stream is online or offline ("stream":null indicates offline stream)
      if self.info.count('"stream":null') &gt; 0:
          return "offline"
      else:
          return "online"
  </code></pre>
  
  <p>main.py:</p>
  
  <pre><code>#imports:
  from classes import *
  
  #consts:
  TWITCH_STREAMS = "https://api.twitch.tv/kraken/streams/?game=" #add the game name at the end of the link (space = "+", eg: Game+Name)
  STREAMER_INFO  = "https://api.twitch.tv/kraken/streams/" #add streamer name at the end of the link
  GAME = "League+of+Legends"
  
  def main():
      #create an information object
      info = Information(TWITCH_STREAMS, GAME, STREAMER_INFO)
  
      streamer_list = [] #create a streamer list
      for name in info.get_game_streamer_names():
          #run for every streamer name, create a streamer object and place it in the list
          mode =  info.get_streamer_mode(name)
          streamer_name = Streamer(name, mode, 'http://twitch.tv/' + name)
          streamer_list.append(streamer_name)
  
      #this line is just to try and print something
      print streamer_list[0].name, streamer_list[0].mode
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>the program itself works perfectly, just really slow</p>
  
  <p>any ideas?</p>