Quick answer: Use pygame.display.flip() for full-screen updates when most of the screen changes each frame. Use pygame.display.update(rect_list) with dirty rectangles when only small regions change. Passing a rect list to update() avoids redrawing the entire screen and can dramatically improve frame rates for UI-heavy or turn-based games.

Here is how to fix Pygame display.flip vs display.update performance. Your game runs at 60 FPS with a simple background, but adding a few more sprites drops it to 30. Or your card game redraws the entire 1920x1080 screen every frame just to animate one card moving. Pygame’s two display update functions look interchangeable but have very different performance characteristics depending on how much of the screen actually changes each frame.

The Symptom

Frame rate drops as resolution or sprite count increases. Profiling shows most time is spent in the display update call, not in game logic or drawing. The game feels sluggish on lower-end hardware even though the scene is visually simple.

Variant: switching from flip() to update() with no arguments makes no difference (because they do the same thing when called without arguments). Or dirty-rect rendering produces visual artifacts because old frames are not cleared properly.

What Causes This

Using flip() when only part of the screen changes. pygame.display.flip() pushes the entire screen buffer to the display. For a 1080p window, that is ~8 MB of pixel data copied per frame. If only a 100x100 sprite moved, 99.5% of that copy was wasted.

Using update() without arguments. pygame.display.update() with no arguments is identical to flip() — it updates the entire screen. The performance benefit only comes when you pass a list of rectangles that changed.

Not tracking dirty rectangles. To use update(rect_list), you need to know which screen regions changed. Without tracking, you either update everything (no gain) or update too little (visual artifacts).

Redrawing everything every frame unnecessarily. Many tutorials teach the pattern of clearing the entire screen with fill() and redrawing everything every frame. This works but wastes CPU when most of the scene is static.

The Fix

Method 1: Full flip for action games. When most of the screen changes every frame (scrolling, particles, many moving objects), full flip is the right choice. Optimize with double buffering:

import pygame
from pygame.locals import DOUBLEBUF

pygame.init()
screen = pygame.display.set_mode((1280, 720), DOUBLEBUF)
clock = pygame.time.Clock()

while True:
    # Clear and redraw everything
    screen.fill((0, 0, 0))
    draw_background(screen)
    draw_sprites(screen)
    draw_ui(screen)

    pygame.display.flip()  # full screen swap
    clock.tick(60)

The DOUBLEBUF flag enables double buffering, which swaps buffers instead of copying — faster on supported hardware.

Method 2: Dirty-rect update for static scenes. For games with mostly static backgrounds (board games, card games, menus):

import pygame

pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()

# Draw background once
background = pygame.image.load("board.png").convert()
screen.blit(background, (0, 0))
pygame.display.flip()  # initial full draw

while True:
    dirty_rects = []

    for sprite in moving_sprites:
        # Erase old position by restoring background
        old_rect = sprite.rect.copy()
        screen.blit(background, old_rect, old_rect)
        dirty_rects.append(old_rect)

        # Update position
        sprite.update()

        # Draw at new position
        screen.blit(sprite.image, sprite.rect)
        dirty_rects.append(sprite.rect.copy())

    # Only update the regions that changed
    pygame.display.update(dirty_rects)
    clock.tick(60)

This updates only the rectangles where sprites moved. For a 1280x720 screen with one 64x64 sprite, you update ~8,192 pixels instead of 921,600 — a 112x reduction.

Method 3: Pygame sprite Groups with dirty tracking. pygame.sprite.RenderUpdates automates dirty-rect tracking:

all_sprites = pygame.sprite.RenderUpdates()

# Add sprites to group
player = Player()
all_sprites.add(player)

while True:
    all_sprites.update()

    # clear() restores background under each sprite
    all_sprites.clear(screen, background)

    # draw() returns list of dirty rects
    dirty = all_sprites.draw(screen)

    pygame.display.update(dirty)
    clock.tick(60)

RenderUpdates tracks both old and new positions and returns the minimal set of dirty rects. This is the most Pygame-idiomatic approach.

Measuring the Difference

Profile both approaches to see the actual impact:

import time

# Benchmark flip
start = time.perf_counter()
for _ in range(1000):
    screen.fill((0, 0, 0))
    pygame.display.flip()
flip_time = time.perf_counter() - start

# Benchmark dirty update
small_rect = pygame.Rect(0, 0, 64, 64)
start = time.perf_counter()
for _ in range(1000):
    pygame.display.update(small_rect)
dirty_time = time.perf_counter() - start

print(f"flip: {flip_time:.3f}s, dirty: {dirty_time:.3f}s")

On a 1080p display, dirty-rect update of a small region is typically 5–15x faster than a full flip.

Understanding the issue

Performance bugs are quality bugs. A 5ms regression on the main update loop affects every player; a 50ms hitch affects only some. Both matter; both are worth tracking and fixing.

The specific bug described above is the kind that surfaces during integration rather than unit testing. It depends on a combination of factors: the asset configuration, the runtime state, the platform's specific behavior. In isolation, each piece looks correct; in combination, the bug emerges. This is why thorough integration testing - playing the actual game in realistic conditions - catches things that automated tests miss.

Why this happens

This bug class disproportionately affects late-stage development. The work to surface it is interactive testing in realistic conditions, which only really happens after the gameplay is in place and assets are populated. Catching it early requires deliberate testing of conditions that look unimportant.

At the engine level, the behavior comes from a deliberate design decision in Pygame. The engine team chose a particular trade-off - usually performance versus convenience, or generality versus specificity - and that trade-off has consequences when you push against it. Understanding the trade-off is what turns 'this bug is mysterious' into 'this bug is the expected consequence of this design'.

Verifying the fix

After applying the fix, the verification step has three parts: confirm the original repro is resolved, confirm no obvious regressions in adjacent functionality, and (for shipping titles) deploy to a small player cohort first and watch the crash and report rates. Each step catches something the others miss.

Reproducibility is the prerequisite for verification. If you can't reliably reproduce the bug pre-fix, you can't reliably verify it post-fix. Spend time getting a clean reproduction before you write any fix code. The fix is fast once you understand the reproduction; the reproduction is the slow part.

Variations to watch for

Related bug classes often share the same root cause. If you find yourself fixing this issue, look for cousins: similar symptoms in adjacent systems, the same data flow but a different value, or the same fix pattern in another module. The catalog of 'we've seen this before' becomes valuable institutional knowledge.

Adjacent bugs often share a root cause. After fixing the case you've found, spend an hour searching the codebase for similar patterns. What's the same call with different arguments? The same data flow with a different entity type? The same lifecycle issue in a sibling system? Each match is a candidate for the same fix, or a related fix that prevents future bugs of the same class.

In production

For shipping titles with a long support window, watch for this issue resurfacing after dependency updates. Engine upgrades, driver updates, OS releases - each one can resurface a bug class you thought you'd fixed because the underlying behavior changed slightly. Regression tests catch the obvious ones; player reports catch the rest.

When triaging a similar issue in production, prioritize gathering data over hypothesizing causes. A player report describes a symptom; what you need is a build SHA, a session timestamp, and ideally a screen recording or session replay. With those, the bug becomes tractable. Without them, you're guessing at hypothetical reproductions that may not match what the player actually hit.

Performance considerations

If this issue manifests under high load (many actors, many particles, many network connections), profile the post-fix code path with realistic counts. The original cost was a bug; the new cost is real work, and real work has a budget.

Diagnostic approach

The diagnostic tools available depend on your engine and platform. Use the engine's native profilers and debug overlays before reaching for external tools. The native tools have context that external tools lack - they know which subsystem owns the code, which assets are loaded, and what state the engine is in.

For Pygame-specific diagnostics, the editor's profiler is the canonical starting point. Capture a representative frame with the symptom present; compare against a frame without the symptom; the diff often points directly at the cause. If the symptom is non-deterministic, capture multiple frames and look for the pattern - the cause is usually a state transition or a specific input value rather than a continuous effect.

Tooling and ecosystem

The tooling around this bug class matters as much as the fix itself. Good logging, accessible profilers, and clear error messages turn 30-minute investigations into 5-minute ones. If your project doesn't have visibility into this code path, the first fix should add the visibility - the second fix uses it.

Within Pygame, the relevant diagnostic surfaces include the standard frame debugger, memory profiler, and engine-specific debug overlays. Each one shows a different facet of what's happening. The frame debugger reveals draw call ordering and state transitions; the memory profiler shows allocation patterns; the debug overlay reveals per-system state. Bugs that resist one tool usually surrender to another - the trick is knowing which tool to reach for first.

Edge cases and pitfalls

Boundary conditions deserve specific testing attention. What happens when the input is zero, maximum, negative, or NaN? What happens at the start of a session vs hours in? What happens at the boundary between two systems handling the same data? These are where bugs hide and where regression tests are most valuable.

When writing a regression test for this fix, focus on the boundary conditions that surfaced the original bug. Tests that exercise the happy path catch obvious regressions; tests that exercise the boundary catch the subtler regressions that look like new bugs but are really the original returning. The latter are the tests that earn their keep over the long life of the project.

Team communication

Document the fix and its rationale in the commit message or attached engineering doc. Future engineers will encounter related issues; the rationale tells them whether your fix is reusable or specific to the case at hand. Without rationale, the fix gets reverted or copied incorrectly.

If this fix touches a system several engineers work in, a short writeup in the team's engineering channel helps. Not a full design doc - a paragraph explaining what was wrong, what's fixed, and what to watch for. Future engineers encountering similar symptoms will search for the fix; making it findable is a small investment that pays back later.

“flip() for action. update(rects) for mostly-static scenes. Match the update strategy to how much actually changes.”

Related Issues

For surface transparency performance, see Pygame Surface Blit Alpha Not Transparent. For general rendering optimization, Best Bug Tracking for Solo Developers covers related development workflow tips.

Track dirty rects for static scenes. Use RenderUpdates for automatic tracking. Full flip when everything moves. Choose based on your game.