Skip to content

Can we cache pyc files #18668

@paddymul

Description

@paddymul

Summary

uv has a --compile-bytecode option which precompiles the bytecode for packages across an entire venv. This results in slightly faster python startup time, but much slower package install time. compiling bytecode is deterministic depending on python version and python source file content. This should be eminently cacheable.

Example

This will be useful for local development where I install the same packages across many different venvs. I currently don't use --compile-bytecode because it's slow, but I would use it if the results were cached.

This also helps in github CI (I think). The astral-sh/setup-uv@v7 job caches the uv cache, not installed venvs. so you could save the --compile-bytecode cost on subsequent runs.

This wouldn't help docker builds, where you can save --compile-bytecode to its own layer. You get the same venv every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions