I am looking to improve performance of my python lamda which copies files on same sftp server for backup. This is my current code:
for attr in sftp_server.listdir_attr():
if dt.datetime.fromtimestamp(attr.st_mtime) > date_limit:
c = sftp_server.open(attr.filename, 'r')
d = c.read()
with sftp_server.open(copy_target_1 + attr.filename, 'w') as x:
x.write(d)
with sftp_server.open(copy_target_2 + attr.filename, 'w') as y:
y.write(d)
c.close()
Is there any way to increase the copy speed? Are there any libraries I can use? Thank you