Open typesupply opened 3 years ago
Search view.__class__.__dict__
for a method unique to vanilla:
def _breakCycles(view):
if "setVanillaWrapper_" in view.__class__.__dict__:
obj = view.vanillaWrapper()
try:
obj._breakCycles()
except AttributeError:
pass
for view in view.subviews():
_breakCycles(view)
Use respondsToSelector
:
def _breakCycles(view):
if view.respondsToSelector_("vanillaWrapper"):
obj = view.vanillaWrapper()
obj._breakCycles()
for view in view.subviews():
_breakCycles(view)
FWIW, the respondsToSelector
method gives me very fast performance.
Closing windows is slow. Example:
This is based on the "Align and Distribute" window in my Pop Up Tools extension, so this is a real world example. This takes about 0.7 seconds to close on my old iMac. This makes the UI feel very laggy.
I've tracked this down to the use of
hasattr
in the ultimate_breakCycles
function. This is called once for every single view in a window, thus the more views a window has, the slower it becomes. I'm trying to find a way to speed this up but the best I'm coming up with are super hacky things like:Edit: This code isn't correct. I'm sketching some new options.
This reduces the _breakCycles time by about 40%, so it's still not great. It seems that a lot of time is wasted when the
try:
fails. I wonder if we could leverage getNSSubclass to give us a faster way to determine if_breakCycles
needs to be called. Maybe we'd keep a set of class names that have gone throughgetNSSubclass
that has a_breakCycles
?cc @justvanrossum @typemytype