Improve load speed for python payload script am: 797756460a am: 104b869a62 am: 2417f0eba7

Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1596615

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4c07d8f1595c8813a5e98eaaf0cdb417e12df374
diff --git a/scripts/update_payload/payload.py b/scripts/update_payload/payload.py
index 6b28046..998703a 100644
--- a/scripts/update_payload/payload.py
+++ b/scripts/update_payload/payload.py
@@ -21,6 +21,7 @@
 
 import hashlib
 import io
+import mmap
 import struct
 import zipfile
 
@@ -123,10 +124,11 @@
     """
     if zipfile.is_zipfile(payload_file):
       with zipfile.ZipFile(payload_file) as zfp:
-        with zfp.open("payload.bin") as payload_fp:
-          self.payload_file = io.BytesIO(payload_fp.read())
+        self.payload_file = zfp.open("payload.bin", "r")
     elif isinstance(payload_file, str):
-      self.payload_file = open(payload_file, "rb")
+      payload_fp = open(payload_file, "rb")
+      payload_bytes = mmap.mmap(payload_fp.fileno(), 0, access=mmap.ACCESS_READ)
+      self.payload_file = io.BytesIO(payload_bytes)
     else:
       self.payload_file = payload_file
     self.payload_file_offset = payload_file_offset