Preskoči na glavni sadržaj
← KolegijiSenior Deep-DivesModul 1 · Konkurentnost i asinkroni interniGIL — što jest, što nijepredict2 / 161
+75 XP
Zadatak
📝 **Zadatak:** Predvidite presudu u tri retka koju isječak ispisuje — jedan redak po vrsti radnog opterećenja, prikazanim redoslijedom. 📋 Implementirajte gornju funkciju. Testovi se pokreću automatski. 💡 **Savjet:** Ponovno pročitajte teoriju ako zapnete.
Predvidi izlaz

Pažljivo pročitaj kod

# 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.

Što će program ispisati? Napiši ovdje:

💬 Rasprava

Budi prvi — postavi pitanje ili podijeli savjet.
Prijavi se kako bi se pridružio raspravi. Čitanje je besplatno.
Učitavanje rasprave…