antigol:

The python list contains only references, so the problem you worry about will never happens.


Oh yeah, I agree, so that wouldn’t really blow up memory, but it still would be less elegant I guess 

torch.empty_like does not only copy the size but also dtype and device.

Oh yeah, true. For some reason, I confused it with torch.empty and assumed it was initiated via dimension info, not an existing array.