For such applications, the array s [j, y] would be of a size at least 5000 times the number of training instances: clearly impractical (but see below for a recently discovered trick).
it is unsurprising that this speedup was forgotten.