Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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