title: My Python for loop is causing a MemoryError. How can I optimize this?
body: <p>I'm trying to compile a list of all the MAC address Apple devices will have. <code>oui.txt</code> tells me Apple has been assigned 77 MAC ranges to use. These ranges come in the form of:</p>
  
  <pre><code>00:00:00
  00:11:11
  etc...
  </code></pre>
  
  <p>This leaves me the last three HEX digits to append. That's <code>16^6</code>. A total of 1291845632 Apple MAC addresses.</p>
  
  <p>The problem I'm having is writing a program to create a list of these MAC addresses. Here's my current code:</p>
  
  <pre><code>import re
  
  apple_mac_range = []
  apple_macs      = []
  
  # Parse the HTML of http://standards.ieee.org/cgi-bin/ouisearch to get the MACs
  with open('apple mac list', 'r') as f:
      for line in f.readlines():
  
          match = re.search(r'[\w\d]{2}-[\w\d]{2}-[\w\d]{2}', line)
  
          if match:
              apple_mac_range.append(match.group().split('-'))
  
  for mac in apple_mac_range:
      for i in range(1, 1291845633):
          print i
  </code></pre>
  
  <p>This gives me a <code>MemoryError</code>... How can I optimize it?</p>