Contact: aviboots(AT)netvision.net.il
40,849 questions
53,254 answers
573 users
# Allocate 1 MB (1,048,576 bytes) one_mb = bytearray(1024 * 1024) print(one_mb[]) ''' run: bytearray(b'\x00\x00\... '''
# Allocate 1 MB as a list of 1,048,576 zeros (each integer takes 1 byte) one_mb = [0] * (1024 * 1024) print(one_mb[0]) ''' run: 0 '''
import numpy as np # Allocate 1 MB as a numpy array of 1,048,576 bytes one_mb = np.zeros(1024 * 1024, dtype=np.uint8) print(one_mb[0]) ''' run: 0 '''