File: .gitignore

Date: 2026-05-29

Time: 11:40

.gitignore — Python Build Artifact Exclusions

Purpose

This file tells Git which files and directories to exclude from version control. In this all-Python repository of ~37 DDIA reference implementations, it keeps three categories of generated artifacts out of commits: bytecode caches, compiled modules, and test runner caches.

Key Components

| Pattern | What it matches | Why it's excluded |

|---------|----------------|-------------------|

| _pycache_/ | CPython bytecode cache directories | Generated per-machine when any .py file is imported; contents are non-portable across Python versions |

| *.pyc | Compiled Python bytecode files | Redundant with _pycache/ on Python 3, but catches .pyc files placed outside pycache_/ (legacy Python 2 layout or manual moves) |

| .pytest_cache/ | Pytest's inter-run cache directory | Stores last-failed info and cache plugin data; machine-local, not useful to other developers |

Patterns

Minimal-surface gitignore. This file contains only what the project actually produces — no speculative entries for IDEs, virtual environments, or OS metadata. That's appropriate for a teaching/reference repo where each module is a standalone .py file with no build system, packaging, or deployment tooling.

Dependencies

Every module in the repo produces _pycache/ on import and .pytestcache/ on test runs. This file affects all 37+ subdirectories uniformly — the patterns use no path prefixes, so they match at any depth in the tree.

Flow

Git consults .gitignore during git add and git status. A file matching any pattern here is treated as untracked-and-ignored: it won't appear in git status output and git add . will skip it. Already-tracked files are unaffected — but nothing in this repo was ever tracked that matches these patterns.

Invariants

Error Handling

Not applicable. .gitignore is declarative; malformed patterns are silently treated as literals (they just won't match anything useful). These three patterns are standard and well-formed.