Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.
Start 7-day trial →
⚡
← Courses
›
Senior Deep-Dives
›
Module 5 · Architecture & Code Review
›
Memory views and the buffer protocol
quiz
68 / 161
🇺🇸
EN
▼
↗
Share
⋯
More
+125 XP
📋
Task
📖
Theory
🤖
AI Help
Task
📝 **Question:** Why use memoryview when slicing a large bytes object? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
🎯 Quiz
Question
📝 **Question:** Why use memoryview when slicing a large bytes object? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
A
`socket.recv_into` only accepts buffers that expose the memoryview protocol, so the wrapping is mandatory by the API
B
Zero-copy slicing — view points at the existing buffer; slicing produces a new view with offset/length but no allocation
C
memoryview operations are explicitly thread-safe under PEP 703 free-threading where bytes/bytearray are not
D
memoryview lookup is faster than tuple indexing because PyMemoryView_FromBuffer skips the bytecode path entirely
Submit answer
💬 Discussion
Be the first to ask a question or share a tip.
Sign in
to join the discussion. Reading is free.
Loading discussion…