Skip to content

Instantly share code, notes, and snippets.

@0x9900
Created October 30, 2016 16:17
Show Gist options
  • Select an option

  • Save 0x9900/3ff3d4a05b9e5062bff871693772ed18 to your computer and use it in GitHub Desktop.

Select an option

Save 0x9900/3ff3d4a05b9e5062bff871693772ed18 to your computer and use it in GitHub Desktop.
Example of mmap use.
from mmap import ACCESS_READ, mmap
with open(filename, 'rb') as f, mmap(f.fileno(), 0, access=ACCESS_READ) as mm:
for byte in mm: # length is equal to the current file size
# Do stuff with byte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment