# Packing

class pygit2.Repository(path: str | None = None, flags: RepositoryOpenFlag = RepositoryOpenFlag.DEFAULT)
  pack(path=None, pack_delegate=None, n_threads=None)

    Pack the objects in the odb chosen by the pack_delegate function and write .pack and .idx files for them.

    Returns: the number of objects written to the pack

    Parameters:

    path

      The path to which the .pack and .idx files should be written. None will write to the default location.

    pack_delegate

      The method which will provide add the objects to the pack builder. Defaults to all objects.

    n_threads

      The number of threads the PackBuilder will spawn. If set to 0, libgit2 will autodetect the number of CPUs.

## The PackBuilder

class pygit2.PackBuilder(repo)
  __len__()
  add(oid)
  add_recur(oid)
  set_threads(n_threads)
  write(path=None)
  property written_objects_count