Closed elicn closed 2 years ago
Hi @erocarrera, Is there anything specific that holds this PR from being merged..? Please let me know if there is something I can do about it.
Hi @elicn. Sorry for the delay, I don't get to work on pefile very regularly. The PR is great and the speed up very significant! I had overlooked #266, thanks for also bringing it to my attention.
Great, thanks!
Thank you as well!
Relocation can take up to several minutes for large files (e.g. 64-bit version of
kernelbase.dll
).The reason is largely because
__data__
stores contents asbytes
, which does not have a__setitem__
method. When data needs to be modified it uses slicing - which casues the entire content to be copied over and over and slow down the entire relocation process. This patch simply turns__data__
into abytearray
and have it leverage its__setitem__
method to modify its contents much faster.Note: after analyzing the slowdown rootcause and writing the patch, I noticed this issue was already reported and had a PR submitted to fix it almost 3 years ago (#266). I don't know why that PR was not accepted, but hopefully a fresh one would do.
Note: this patch does not maintain compatibility to Python2