Delay load some particularly heavy stdlib modules that are not often needed
This commit is contained in:
parent
86686bfac7
commit
de1a2f7682
@ -6,7 +6,6 @@ import atexit
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import socket
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from weakref import WeakValueDictionary
|
from weakref import WeakValueDictionary
|
||||||
@ -43,6 +42,7 @@ def initialize_renderer():
|
|||||||
|
|
||||||
|
|
||||||
def listen_on(spec):
|
def listen_on(spec):
|
||||||
|
import socket
|
||||||
family, address, socket_path = parse_address_spec(spec)
|
family, address, socket_path = parse_address_spec(spec)
|
||||||
s = socket.socket(family)
|
s = socket.socket(family)
|
||||||
atexit.register(remove_socket_file, s, socket_path)
|
atexit.register(remove_socket_file, s, socket_path)
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
@ -349,6 +348,7 @@ def print_help_for_seq(seq, usage, message, appname):
|
|||||||
|
|
||||||
text = '\n'.join(blocks) + '\n\n' + version()
|
text = '\n'.join(blocks) + '\n\n' + version()
|
||||||
if print_help_for_seq.allow_pager and sys.stdout.isatty():
|
if print_help_for_seq.allow_pager and sys.stdout.isatty():
|
||||||
|
import subprocess
|
||||||
p = subprocess.Popen(['less', '-isRXF'], stdin=subprocess.PIPE)
|
p = subprocess.Popen(['less', '-isRXF'], stdin=subprocess.PIPE)
|
||||||
p.communicate(text.encode('utf-8'))
|
p.communicate(text.encode('utf-8'))
|
||||||
raise SystemExit(p.wait())
|
raise SystemExit(p.wait())
|
||||||
@ -577,6 +577,7 @@ def create_opts(args, debug_config=False):
|
|||||||
print(version(add_rev=True))
|
print(version(add_rev=True))
|
||||||
print(' '.join(os.uname()))
|
print(' '.join(os.uname()))
|
||||||
if is_macos:
|
if is_macos:
|
||||||
|
import subprocess
|
||||||
print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip())
|
print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip())
|
||||||
else:
|
else:
|
||||||
print('Running under:', green('Wayland' if is_wayland else 'X11'))
|
print('Running under:', green('Wayland' if is_wayland else 'X11'))
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import json
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
@ -449,6 +448,7 @@ def build_ansi_color_table(opts=defaults):
|
|||||||
|
|
||||||
|
|
||||||
def atomic_save(data, path):
|
def atomic_save(data, path):
|
||||||
|
import tempfile
|
||||||
fd, p = tempfile.mkstemp(dir=os.path.dirname(path), suffix='.tmp')
|
fd, p = tempfile.mkstemp(dir=os.path.dirname(path), suffix='.tmp')
|
||||||
try:
|
try:
|
||||||
with os.fdopen(fd, 'wb') as f:
|
with os.fdopen(fd, 'wb') as f:
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import socket
|
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -41,6 +40,7 @@ will only work if this process is run within an existing kitty window.
|
|||||||
|
|
||||||
|
|
||||||
def do_io(to, send, no_response):
|
def do_io(to, send, no_response):
|
||||||
|
import socket
|
||||||
send = ('@kitty-cmd' + json.dumps(send)).encode('ascii')
|
send = ('@kitty-cmd' + json.dumps(send)).encode('ascii')
|
||||||
send = b'\x1bP' + send + b'\x1b\\'
|
send = b'\x1bP' + send + b'\x1b\\'
|
||||||
if to:
|
if to:
|
||||||
|
|||||||
@ -8,11 +8,8 @@ import fcntl
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import socket
|
|
||||||
import string
|
import string
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
|
||||||
@ -121,6 +118,7 @@ def command_for_open(program='default'):
|
|||||||
|
|
||||||
|
|
||||||
def open_cmd(cmd, arg=None, cwd=None):
|
def open_cmd(cmd, arg=None, cwd=None):
|
||||||
|
import subprocess
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
cmd = list(cmd)
|
cmd = list(cmd)
|
||||||
cmd.append(arg)
|
cmd.append(arg)
|
||||||
@ -201,6 +199,8 @@ def remove_socket_file(s, path=None):
|
|||||||
|
|
||||||
|
|
||||||
def single_instance_unix(name):
|
def single_instance_unix(name):
|
||||||
|
import socket
|
||||||
|
import tempfile
|
||||||
home = os.path.expanduser('~')
|
home = os.path.expanduser('~')
|
||||||
candidates = [tempfile.gettempdir(), home]
|
candidates = [tempfile.gettempdir(), home]
|
||||||
if is_macos:
|
if is_macos:
|
||||||
@ -239,6 +239,7 @@ def single_instance_unix(name):
|
|||||||
|
|
||||||
|
|
||||||
def single_instance(group_id=None):
|
def single_instance(group_id=None):
|
||||||
|
import socket
|
||||||
name = '{}-ipc-{}'.format(appname, os.geteuid())
|
name = '{}-ipc-{}'.format(appname, os.geteuid())
|
||||||
if group_id:
|
if group_id:
|
||||||
name += '-{}'.format(group_id)
|
name += '-{}'.format(group_id)
|
||||||
@ -264,6 +265,7 @@ def single_instance(group_id=None):
|
|||||||
|
|
||||||
|
|
||||||
def parse_address_spec(spec):
|
def parse_address_spec(spec):
|
||||||
|
import socket
|
||||||
protocol, rest = spec.split(':', 1)
|
protocol, rest = spec.split(':', 1)
|
||||||
socket_path = None
|
socket_path = None
|
||||||
if protocol == 'unix':
|
if protocol == 'unix':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user