Consider the following two algorithms with regards to the constructing the dataset loader:

Before looping through the training epochs
Within the loop for each epoch

Does the first algorithm have a SIGNIFICANT advantage over the second one?