diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2023-01-10 07:51:23 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2023-01-10 07:52:27 -0500 |
commit | 1cd22f097aca2667cbfde6320178e2354d07199b (patch) | |
tree | d326a6d543068c608142b9a5da931bd9475bdad0 /paramiko/packet.py | |
parent | a9ead5ec359038efc96603ad28b0f2eb9255ec3b (diff) | |
download | paramiko-1cd22f097aca2667cbfde6320178e2354d07199b.tar.gz |
Improve performance by reducing expensive bytes conversion
In two core parts of the codebase, complex type-switch based code is used to convert a value to bytes. However, in all cases (except for one, fixed in this PR), the caller is specifying a Message instance. We can make this code much simpler by directly calling the correct method on Message.
In #2110 this is measured to massively speed up large SFTP transfers.
Diffstat (limited to 'paramiko/packet.py')
-rw-r--r-- | paramiko/packet.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/paramiko/packet.py b/paramiko/packet.py index a8db2582..b6498c5e 100644 --- a/paramiko/packet.py +++ b/paramiko/packet.py @@ -390,7 +390,7 @@ class Packetizer(object): Write a block of data using the current cipher, as an SSH block. """ # encrypt this sucka - data = asbytes(data) + data = data.asbytes() cmd = byte_ord(data[0]) if cmd in MSG_NAMES: cmd_name = MSG_NAMES[cmd] |