Memory mapping is an alternative approach to file I/O that’s available to Python programs through the
mmap module. Memory mapping uses lower-level operating system APIs to store file contents directly in physical memory. This approach often results in improved I/O performance because it avoids many costly system calls and reduces expensive data buffer transfers.
In this video course, you learned:
- What the differences are between physical, virtual, and shared memory
- How to optimize memory use with memory mapping
- How to use Python’s
mmapmodule to implement memory mapping in your code
mmap API is similar to the regular file I/O API, so it’s fairly straightforward to test out. Give it a shot in your own code to see if your program can benefit from the performance improvements offered by memory mapping.
To learn more about the concepts you covered in this course, check out:
- Python documentation: mmap — Memory-mapped file support
- Strings and Character Data in Python
- Speed Up Your Python Program With Concurrency
- Speed Up Python With Concurrency
- Learning Path: Python Concurrency & Parallel Programming
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.