I am using numpy.asarray in my project to handle arrays due to its superb efficiency comparing with default Python lists. I am also supposed to take care of memory utilization when allocating the array because my program can receive big data in gigabytes. While checking numpy.asarray, I found out that the data type is inferred from the array itself unless stated. Thus, I have the following array:
np.asarray([list(map(int, list(x))) for x in X])
When I print print X.dtype, I got int64. Since the array X here always contains binary values, 0 or 1, I thought to use dtype=np.int8 to reduce the memory needed when allocating space. But I am not sure if this is a good idea! Should I stick with the default int64? Could int8 lose any data precisions that I cannot think of?
Thank you.