Recall & Review
beginner
What is a memory-mapped file in the context of numpy's np.memmap?
A memory-mapped file is a way to access small parts of large files on disk as if they were in memory, without loading the entire file. np.memmap lets numpy treat disk files like arrays, saving memory and speeding up access.
Click to reveal answer
beginner
How does np.memmap help when working with large datasets?
np.memmap allows you to work with large datasets by loading only parts of the data into memory on demand, instead of loading the whole dataset at once. This reduces memory use and can improve performance.
Click to reveal answer
intermediate
What are the key parameters when creating a np.memmap object?
Key parameters include: filename (path to the file), dtype (data type of the array), mode ('r', 'r+', 'w+', etc. for read/write), offset (where to start reading), and shape (array dimensions).
Click to reveal answer
beginner
True or False: Changes made to a np.memmap array are immediately saved to the disk file.
True. When you modify a np.memmap array, the changes are written directly to the disk file, making it useful for large data that doesn't fit in memory.
Click to reveal answer
intermediate
Why might you choose np.memmap over loading a numpy array with np.load?
np.memmap is better for very large files because it doesn't load the entire file into memory. np.load loads the whole array into RAM, which can cause memory errors with big data.
Click to reveal answer
What does np.memmap primarily help with?
✗ Incorrect
np.memmap allows working with large files by mapping them to memory, avoiding loading the entire file.
Which mode in np.memmap allows read and write access to the file?
✗ Incorrect
Mode 'r+' opens the file for reading and writing without truncating it.
If you want to start reading a np.memmap file from byte 1000, which parameter do you use?
✗ Incorrect
The offset parameter sets the starting byte position in the file.
True or False: np.memmap loads the entire file into RAM immediately.
✗ Incorrect
np.memmap loads data on demand, not the entire file at once.
What happens when you modify data in a np.memmap array?
✗ Incorrect
Modifications to np.memmap arrays write directly to the disk file.
Explain how np.memmap helps manage large datasets that don't fit into memory.
Think about how you can open a huge book and read only one page at a time.
You got /4 concepts.
Describe the main parameters needed to create a np.memmap object and their roles.
Consider what you need to tell numpy about the file and how you want to use it.
You got /5 concepts.