Python – Binary array in python


How to create big array in python, how efficient creating that

in C/C++:

byte *data = (byte*)memalloc(10000);


byte *data = new byte[10000];

in python…?

Best Solution

Have a look at the array module:

import array
array.array('B', [0] * 10000)

Instead of passing a list to initialize it, you can pass a generator, which is more memory efficient.