My Python for loop is causing a MemoryError. How can I optimize this?

后端 未结 5 1072
抹茶落季
抹茶落季 2021-01-19 06:45

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 i

5条回答
  •  春和景丽
    2021-01-19 07:44

    Well, to start with, range(1, 1291845633) creates a list containing about a billion entries. Since each entry is at least sizeof(Py_Object), it's not too surprising that you run right out of memory. Don't do that.

提交回复
热议问题