How to determine whether the UIList list_index was changed through the UI or programmatically?

I have a Collection Property. IntProperty list_index points to the current index.
There is also a list_index update function.
If list_index was changed via UIList Click item I want to execute computationally expensive code.
If list_index was changed programmatically from my addon, I want to avoid running this code to optimize resources.

if you’re writing the code for the list update, and you’re writing the code to change the list index, it seems trivial to set a flag somewhere that you can check before you do the computationally expensive code?

This is a really working method. I thought about this. The computationally expensive code includes statements for changing the mesh in edit mode. Therefore, I hoped that there was some kind of automatic method so as not to be distracted by setting the flag. Thanks a lot for the advice!