You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use case : Each element in a list is run through supports_protocol to create a derivative list of objects where the derivative list only contains objects that support the interface/protocol of interest.
In [1]: from traits.adaptation.tests.interface_examples import UKPlug
In [3]: import time
In [4]: from traits.adaptation.tests.interface_examples import UKStandard
In [7]: from traits.adaptation.api import supports_protocol
In [8]: supports_protocol(UKPlug(), UKStandard)
Out[8]: True
In [9]: for num_plugs in [10, 10**2, 10**3, 10**4]:
...: plugs = [UKPlug() for _ in range(num_plugs)]
...: start = time.time()
...: supported_plugs = [plug for plug in plugs if supports_protocol(plug, UKStandard)]
...: print(time.time() - start)
...:
3.552436828613281e-05
0.00019216537475585938
0.0018210411071777344
0.02335357666015625
The text was updated successfully, but these errors were encountered:
Use case : Each element in a list is run through
supports_protocol
to create a derivative list of objects where the derivative list only contains objects that support the interface/protocol of interest.The text was updated successfully, but these errors were encountered: