Code Room
Code reviewMediumcr-g284
Subject Inefficient data structureLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Python function that filters incoming events to those whose user is on an allowlist. The allowlist is loaded from config and can hold tens of thousands of ids.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def filter_allowed(events, allowlist):    # allowlist is a list of user_ids loaded from config    allowed = []    for e in events:        if e.user_id in allowlist:            allowed.append(e)    return allowed
Run or narrate your approach, then ask the coach.