Saltar al contenido principal
🔒 Modo vista previa. Las primeras quince lecciones de Foundations son gratis; esta es Pro. Inicia un trial de 7 días para desbloquear el editor, las pistas AI y el resto del programa. Tarjeta requerida, cancela cuando quieras en Dashboard.Iniciar trial de 7 días →
← CursosSenior Deep-DivesModule 1 · Concurrency internals · RecapVistas de memoria y protocolo de búfer.predict32 / 161
+100 XP
Tarea🌐 shown in EN
📝 **Question:** Predict the exact output. \`mv = memoryview(data)\` is a zero-copy WINDOW into the bytearray. Then \`slice_view = mv[0:5]\` is a smaller window into the SAME buffer. The question: does writing through \`slice_view\` change \`data\`? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Predice la salida

Lee el código con atención

data = bytearray(b"hello world")
mv = memoryview(data)
print(f"original:{data.decode()}")

mv[6:11] = b"PYTHN"
print(f"after_view_write:{data.decode()}")

slice_view = mv[0:5]
print(f"slice:{bytes(slice_view).decode()}")

slice_view[0] = ord("H")
print(f"data_now:{data.decode()}")
print(f"mv_view:{bytes(mv).decode()}")

¿Qué imprimirá el programa? Escribe aquí: