Crank zlib.compress() upto 9

SSH command size: 482 bytes (no change)
Preamble size: 8946 bytes (down 33)
wip-fakessh-exit-status
Alex Willmer 7 years ago committed by David Wilson
parent 9aa83ef77f
commit f999b9adbf

@ -445,7 +445,7 @@ class Importer(object):
'mitogen.core', 'mitogen.core',
None, None,
'mitogen/core.py', 'mitogen/core.py',
zlib.compress(core_src), zlib.compress(core_src, 9),
[], [],
) )

@ -522,13 +522,12 @@ class ModuleResponder(object):
if fullname == '__main__': if fullname == '__main__':
source = self.neutralize_main(source) source = self.neutralize_main(source)
compressed = zlib.compress(source) compressed = zlib.compress(source, 9)
related = [ related = [
name name
for name in self._finder.find_related(fullname) for name in self._finder.find_related(fullname)
if not mitogen.core.is_blacklisted_import(self, name) if not mitogen.core.is_blacklisted_import(self, name)
] ]
# 0:fullname 1:pkg_present 2:path 3:compressed 4:related # 0:fullname 1:pkg_present 2:path 3:compressed 4:related
tup = fullname, pkg_present, path, compressed, related tup = fullname, pkg_present, path, compressed, related
self._cache[fullname] = tup self._cache[fullname] = tup

@ -345,7 +345,7 @@ class Stream(mitogen.core.Stream):
source = textwrap.dedent('\n'.join(source.strip().split('\n')[2:])) source = textwrap.dedent('\n'.join(source.strip().split('\n')[2:]))
source = source.replace(' ', '\t') source = source.replace(' ', '\t')
source = source.replace('CONTEXT_NAME', self.remote_name) source = source.replace('CONTEXT_NAME', self.remote_name)
encoded = source.encode('zlib').encode('base64').replace('\n', '') encoded = zlib.compress(source, 9).encode('base64').replace('\n', '')
# We can't use bytes.decode() in 3.x since it was restricted to always # We can't use bytes.decode() in 3.x since it was restricted to always
# return unicode, so codecs.decode() is used instead. In 3.x # return unicode, so codecs.decode() is used instead. In 3.x
# codecs.decode() requires a bytes object. Since we must be compatible # codecs.decode() requires a bytes object. Since we must be compatible
@ -372,7 +372,7 @@ class Stream(mitogen.core.Stream):
'blacklist': self._router.get_module_blacklist(), 'blacklist': self._router.get_module_blacklist(),
},) },)
compressed = zlib.compress(minimize_source(source)) compressed = zlib.compress(minimize_source(source), 9)
return str(len(compressed)) + '\n' + compressed return str(len(compressed)) + '\n' + compressed
create_child = staticmethod(create_child) create_child = staticmethod(create_child)

Loading…
Cancel
Save