As shown in the answer to the question Convert python list with None values to numpy array with nan values, it is straightforward to initialize a masked numpy array from a list with None values if we enforce the dtype=float. Those float values get converted to nan and we can simply do:
ma.masked_invalid(np.array(a, dtype=float), copy=False)
This however will not work for int like:
ma.masked_invalid(np.array(a, dtype=int), copy=False)
since the intermediate np.array will not be created with None values (there is no int nan).
What is the most efficient way to initialize a masked array based on Python list of ints that also contains None values in such way that those None values become masked?