1Hardconcurrencyโฑ 45s
What is the Global Interpreter Lock (GIL) in CPython and what does it prevent?
โผ
What is the Global Interpreter Lock (GIL) in CPython and what does it prevent?
What is the output of this decorator example?
def decorator(fn):
def wrapper(*args, **kwargs):
print('before')
result = fn(*args, **kwargs)
print('after')
return result
return wrapper
@decorator
def greet(name):
print(f'Hello, {name}')
return 'done'
result = greet('Alice')What is the difference between @staticmethod and @classmethod in Python?
What are Python generators and what advantage do they have over regular functions that return lists?
def count_up(n):
i = 0
while i < n:
yield i
i += 1
gen = count_up(1_000_000)
print(next(gen), next(gen))What is a metaclass in Python and when would you use one?
What is the purpose of asyncio in Python and what concurrency model does it use?
What is the output of this code about Python's default mutable argument pitfall?
def append_to(element, lst=[]):
lst.append(element)
return lst
print(append_to(1))
print(append_to(2))
print(append_to(3, []))What is the difference between __str__ and __repr__ in Python?