Saltar al contenido principal
← CursosSenior Deep-DivesMódulo 1 · Concurrencia y aspectos internos asincrónicosEl GIL: qué es y qué no espredict2 / 161
+75 XP
Tarea
📝 **Tarea:** Predecir el veredicto de tres líneas que imprime el fragmento: una línea por tipo de carga de trabajo, en el orden que se muestra. 📋 Implemente la función anterior. Las pruebas se ejecutan automáticamente. 💡 **Pista:** Vuelve a leer la teoría si te quedas atascado.
Predice la salida

Lee el código con atención

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

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

💬 Discusión

Sé el primero en hacer una pregunta o compartir un consejo.
Inicia sesión para unirte a la discusión. Leer es gratis.
Cargando discusión…