File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,19 @@ def bytes_to_string(buf):
6060 return '/' .join (st )
6161
6262
63+ int_to_hex = None
64+ encode_big_endian_16 = None
65+
66+
6367def address_string_to_bytes (proto , addr_string ):
64- from .util import int_to_hex
65- from .util import encode_big_endian_16
68+ global int_to_hex
69+ if int_to_hex is None :
70+ from .util import int_to_hex
71+
72+ global encode_big_endian_16
73+ if encode_big_endian_16 is None :
74+ from .util import encode_big_endian_16
75+
6676 if proto .code == P_IP4 : # ipv4
6777 try :
6878 ip = IPAddress (addr_string )
@@ -143,8 +153,13 @@ def address_string_to_bytes(proto, addr_string):
143153 raise ValueError ("failed to parse %s addr: unknown" % proto .name )
144154
145155
156+ decode_big_endian_16 = None
157+
158+
146159def address_bytes_to_string (proto , buf ):
147- from .util import decode_big_endian_16
160+ global decode_big_endian_16
161+ if decode_big_endian_16 is None :
162+ from .util import decode_big_endian_16
148163 if proto .code == P_IP4 :
149164 return str (IPAddress (int (buf , 16 ), 4 ).ipv4 ())
150165 elif proto .code == P_IP6 :
You can’t perform that action at this time.
0 commit comments