iterate through all clips

Tom Langfeldt's icon

I am trying to iterate through all the clips in my live_set / song to gather midi data out of those clips. This is the current solution i managed to come with, but it feels highly unoptimised.

What would be the best way of accessing all the clips in my current live_set / Song ?

Thank you for your help.

EDIT:

ok so using the id directly linked to functions or properties avoids me using goto statements, but do is still need to iterate over everything ?

this is doing the job but takes a lot of execution time.