Zum Hauptinhalt springen
← KurseSenior Deep-DivesModul 1 · Parallelität und asynchrone InternaDie GIL – was sie ist und was nichtpredict2 / 161
+75 XP
Aufgabe
📝 **Aufgabe:** Sagen Sie das dreizeilige Urteil voraus, das das Snippet ausgibt – eine Zeile pro Workload-Art, in der angezeigten Reihenfolge. 📋 Implementieren Sie die obige Funktion. Tests laufen automatisch ab. 💡 **Hinweis:** Lesen Sie die Theorie noch einmal, wenn Sie nicht weiterkommen.
Sage die Ausgabe vorher

Lies den Code sorgfältig

# Each function reports whether moving from 1 thread to 4 threads
# in CPython would yield a real speedup. The verdict is decided
# by the GIL rules, NOT by wall-clock measurement.

def cpu_bound():
    # Pure Python tight loop — GIL serializes every bytecode op.
    return "no_speedup"

def io_bound():
    # time.sleep / socket waits release the GIL.
    return "speedup"

def numpy_bound():
    # NumPy's C code releases the GIL during heavy array ops.
    return "speedup"

print(cpu_bound())
print(io_bound())
print(numpy_bound())

# What does this print? Type your prediction.

Was wird das Programm ausgeben? Schreib hier:

💬 Diskussion

Sei der erste — stelle eine Frage oder teile einen Tipp.
Anmelden um an der Diskussion teilzunehmen. Lesen ist kostenlos.
Diskussion wird geladen…