Yes.
Speed-wise they are the same.
But for your application, I would recommend the sum, so that training sample[0] will behavior the same if len(sample) = 10 or len(sample) = 100.
If you do the mean, then you will have to scale your lr up when len(sample) increases.