Recall & Review
beginner
What is a memory-mapped array in NumPy?
A memory-mapped array is a way to access large data stored on disk as if it were in memory, without loading the entire data into RAM. It allows working with data too big to fit in memory by loading only needed parts.
Click to reveal answer
beginner
How do you create a memory-mapped array in NumPy?
Use
numpy.memmap(filename, dtype, mode, shape) to create a memory-mapped array. It links the array to a file on disk, specifying data type, access mode, and shape.Click to reveal answer
beginner
Why use memory-mapped arrays instead of loading the whole file into memory?
Memory-mapped arrays let you work with files larger than your RAM by loading only parts you need. This saves memory and speeds up processing for big data.Click to reveal answer
intermediate
What does the
mode parameter in numpy.memmap control?The
mode controls how the file is opened: 'r' for read-only, 'r+' for read-write, 'w+' to create or overwrite, and 'c' for copy-on-write.Click to reveal answer
intermediate
Can you modify data in a memory-mapped array?
Yes, if you open the memory-mapped array in a write mode like
'r+' or 'w+', you can change data and it will be saved back to the file on disk.Click to reveal answer
What is the main advantage of using a memory-mapped array?
✗ Incorrect
Memory-mapped arrays let you access large files without loading all data into RAM, improving memory use.
Which NumPy function creates a memory-mapped array?
✗ Incorrect
numpy.memmap() creates a memory-mapped array linked to a file.If you want to modify a memory-mapped array and save changes, which mode should you use?
✗ Incorrect
Mode
'r+' opens the file for reading and writing, allowing changes to be saved.What happens if you open a memory-mapped array with mode 'c'?
✗ Incorrect
Mode
'c' creates a copy-on-write mapping; changes are not saved back to the file.Which of these is NOT a benefit of memory-mapped arrays?
✗ Incorrect
Memory-mapped arrays do not clean data; they only manage how data is loaded and accessed.
Explain how memory-mapped arrays help when working with very large datasets.
Think about how you might read a huge book by opening only the pages you need.
You got /3 concepts.
Describe the steps to create and use a memory-mapped array in NumPy.
Remember the function and what parameters it needs.
You got /3 concepts.