ID 590573 - Updating Clip Soft Effects via Python is much slower when the Project Bin is fully expanded

Follow

Problem summary:
Updating Clip Soft Effects via Python is much slower when the Project Bin is fully expanded
 
Customer reported version:
Nuke Studio N/A
 
Customer reported platform:
N/A
 
Steps to reproduce:
1) Launch Nuke Studio and run the following code in the Script Editor to add 300 Clips that each contain a Grade Soft Effect to the Project: 
from hiero.core import MediaSource, Clip, BinItem def makeOfflineClips(project, endFrame, quantity):     for i in range(quantity):         offline = MediaSource.createOfflineVideoMediaSource(f"/tmp/clip_{i}.######.exr", 1, endFrame, 24)         clip = Clip(offline)         clip.createEffect("Grade")         project.clipsBin().addItem(BinItem(clip)) project = hiero.core.projects()[-1] makeOfflineClips(project, 24, 300)
2) Next, execute the following code to create a function that will disable or enable the Soft Effects in each Clip:
import timeflag = Truedef toggle_effects(checked):     action_name = "Enable Clip Effects" if checked else "Disable Clip Effects"     project.beginUndo(action_name)     for clip in project.clips():         effects = clip.effects()         for effect in effects:             effect.setEnabled(checked)     project.endUndo()
3) Run the following lines a few times to execute the function, and note how it generally takes 2.5 seconds to complete:
start = time.perf_counter() toggle_effects(flag) end = time.perf_counter()flag = not flagprint(f'Toggle Effects took {end - start:.6f} seconds to execute')

4) Collapse the Project Bin, or completely close the Project window.
5) Run the code in step 3 again, observing how it now only takes approximately 0.1 seconds to complete:

 
Expected behavior:
Having the Project Bin open should not greatly impact the performance of Python scripts.
 
Actual behavior:
When the Project Bin and/or its sub-Bins are fully expanded, attempting to adjust a Clip's Soft Effects via Python will take longer than expected. Launching with the HIERO_DISABLE_THUMBNAILS=1 environment variable does not alter the results.

There is still a considerable difference in computation time on macOS, but the change is from 0.9 seconds to 0.04 seconds.
 
Workaround:
Besides collapsing the Project Bin, there are no known workarounds at this time. To collapse the Project Bin via Python, code similar to the following could be used:
for widget in hiero.ui.windowManager().windows():     if widget.windowTitle() == "Project":         binView = widget         binTreeViews = binView.findChildren(QTreeView) for treeview in binTreeViews:     treeview.collapseAll()
 
Reproduced by Support in:
Nuke Studio 15.1v4 - Windows 10, macOS 14 Sonoma
Nuke Studio 15.1v1 - Windows 10, macOS 14 Sonoma
 
Earliest version tested:
Nuke Studio 15.1v1 - This feature (the ability to create and get Clip effects via Python) did not exist before this version

    We're sorry to hear that

    Please tell us why