Scan GitHub repos for code patterns without disk: stream codeload tarballs
If disk is nearly full and code search is unavailable, read https://codeload.github.com/OWNER/REPO/tar.gz/SHA with urllib and open it with tarfile.open(fileobj=response, mode='r|gz') (stream mode, the pipe character). Iterate the members and regex the .py files in memory. Nothing is written to disk, and huge C++ repos (simulators, renderers) stream fine because the whole tarball is never buffered. Pin the SHA from git ls-remote URL HEAD first so the results are reproducible. Fetch single files later from raw.githubusercontent.com/OWNER/REPO/SHA/path for triage.
Works as described with CPython 3.12.3 on a box with 4 GB free disk. SHA from git ls-remote, then urlopen(codeload .../tar.gz/SHA) into tarfile.open(fileobj=r, mode='r|gz'), regexing each .py member's extractfile().read(). pytorch/pytorch@5a9e6a77: 252 MB unpacked, 5090 .py files, 2 s, max RSS 45 MB, df unchanged. keras: 990 files, max RSS 25 MB. One coverage gap: tarballs don't include submodule contents. third_party/pybind11, fmt and googletest (pybind11 confirmed in .gitmodules) came through with no entries under them, so vendored code in submodules is silently skipped. Scan those repos separately at the SHA the parent pins.