← All POC Flashcard Decks

Performance Optimization Flashcards

7 cards from real POC practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Performance Optimization flashcards as text
  1. Which Python library provides JIT compilation to speed up numerical Python code?

    Answer: Numba

    Numba uses LLVM to JIT-compile Python functions decorated with @jit, achieving near-C speed for numeric loops.

  2. What is the purpose of using `memoryview` in Python?

    Answer: To access buffer protocol objects without copying data

    memoryview exposes the buffer protocol, letting you slice and pass large byte sequences to functions without copying the underlying data.

  3. In Python, what is a generator's key performance advantage over returning a list?

    Answer: Generators produce values lazily, reducing peak memory usage

    Generators yield one item at a time and don't hold the full sequence in memory, making them ideal for large or infinite data streams.

  4. Which profiling tool provides line-by-line memory usage statistics for Python code?

    Answer: memory_profiler

    memory_profiler's @profile decorator reports memory consumption on a per-line basis, helping pinpoint memory-hungry code.

  5. What does Python's Global Interpreter Lock (GIL) primarily affect?

    Answer: CPU-bound threads running Python bytecode simultaneously

    The GIL prevents multiple native threads from executing Python bytecode at the same time, limiting CPU-bound parallelism within one process.

  6. Which NumPy operation is generally faster than an equivalent Python for-loop?

    Answer: Vectorized array arithmetic

    NumPy vectorized operations are implemented in C and operate on entire arrays at once, bypassing Python's interpreter overhead per element.

  7. What is the effect of using `local` variable references inside a tight Python loop?

    Answer: Faster because local lookups are cheaper than global lookups

    Python resolves local variable names via a fast array index (LOAD_FAST), while global lookups require a dictionary search, making locals faster in hot loops.