c - How to improve speed of saving serial data to file in Python -
i'm trying implement ramdump pc program can of ram data smart phone. code works, slow because of file writing. how can improve file-writing speed in python?
this part of code receive serial data:
while recv_num < tot_num: remain_num = tot_num - recv_num in range(512): data = receive_qword() # result=ser.read(size=8) f.write(data) recv_num = recv_num + 512
i have ramdump program written in c, , working on converting python. in c code function f_write(fil, ptr, size * count, &bwrite) works rapidly , seems operate bulk steam.
is there mechanism in python equivalent c mechanism?
try this
import array while recv_num<tot_num: remain_num=tot_num-recv_num buffer = bytearray() in range(512): buffer.extend(receive_qword()) # result=ser.read(size=8) f.write(buffer) #yep, after loop. recv_num = recv_num + 512
and sure need read in 8-packs? why not ser.read(512)
?
Comments
Post a Comment