I'm trying to compile a list of all the MAC address Apple devices will have. oui.txt
tells me Apple has been assigned 77 MAC ranges to use. These ranges come in the form of:
00:00:00
00:11:11
etc...
This leaves me the last three HEX digits to append. That's 16^6
. A total of 1291845632 Apple MAC addresses.
The problem I'm having is writing a program to create a list of these MAC addresses. Here's my current 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
This gives me a MemoryError
... How can I optimize it?