6
6
7
7
from .compiler import compiler
8
8
9
- _RemoteConnection = None
10
- ClockLine = None
11
- PseudoClockDevice = None
9
+ cached_RemoteConnection = None
10
+ cached_ClockLine = None
11
+ cached_PseudoclockDevice = None
12
12
13
13
14
14
def is_remote_connection (connection ):
@@ -19,9 +19,11 @@ def is_remote_connection(connection):
19
19
maintaining reasonable performance (this performs better than importing each time as
20
20
the lookup in the modules hash table is slower).
21
21
"""
22
- if _RemoteConnection is None :
22
+ global cached_RemoteConnection
23
+ if cached_RemoteConnection is None :
23
24
from .remote import _RemoteConnection
24
- return isinstance (connection , _RemoteConnection )
25
+ cached_RemoteConnection = _RemoteConnection
26
+ return isinstance (connection , cached_RemoteConnection )
25
27
26
28
27
29
def is_clock_line (device ):
@@ -32,22 +34,26 @@ def is_clock_line(device):
32
34
maintaining reasonable performance (this performs better than importing each time as
33
35
the lookup in the modules hash table is slower).
34
36
"""
35
- if ClockLine is None :
37
+ global cached_ClockLine
38
+ if cached_ClockLine is None :
36
39
from .core import ClockLine
37
- return isinstance (device , _RemoteConnection )
40
+ cached_ClockLine = ClockLine
41
+ return isinstance (device , cached_ClockLine )
38
42
39
43
40
44
def is_pseudoclock_device (device ):
41
45
"""Returns whether the connection is an instance of ``PseudoclockDevice``
42
46
43
- This function defers and caches the import of ``_RemoteConnection ``. This both
44
- breaks the circular import between ``Device`` and ``_RemoteConnection ``, while
47
+ This function defers and caches the import of ``PseudoclockDevice ``. This both
48
+ breaks the circular import between ``Device`` and ``PseudoclockDevice ``, while
45
49
maintaining reasonable performance (this performs better than importing each time as
46
50
the lookup in the modules hash table is slower).
47
51
"""
48
- if PseudoclockDevice is None :
52
+ global cached_PseudoclockDevice
53
+ if cached_PseudoclockDevice is None :
49
54
from .core import PseudoclockDevice
50
- return isinstance (device , PseudoclockDevice )
55
+ cached_PseudoclockDevice = PseudoclockDevice
56
+ return isinstance (device , cached_PseudoclockDevice )
51
57
52
58
53
59
def set_passed_properties (property_names = None ):
@@ -182,7 +188,7 @@ def bitfield(arrays,dtype):
182
188
return y
183
189
184
190
185
- @contextlib .contextmanager ()
191
+ @contextlib .contextmanager
186
192
def suppress_mild_warnings (state = True ):
187
193
"""A context manager which modifies compiler.suppress_mild_warnings
188
194
@@ -199,7 +205,7 @@ def suppress_mild_warnings(state=True):
199
205
compiler .suppress_mild_warnings = previous_warning_setting
200
206
201
207
202
- @contextlib .contextmanager ()
208
+ @contextlib .contextmanager
203
209
def suppress_all_warnings (state = True ):
204
210
"""A context manager which modifies compiler.suppress_all_warnings
205
211
0 commit comments