gc.pyi 848 B

123456789101112131415161718192021222324252627
  1. from typing import Callable
  2. def isenabled() -> bool:
  3. """Check if automatic garbage collection is enabled."""
  4. def enable() -> None:
  5. """Enable automatic garbage collection."""
  6. def disable() -> None:
  7. """Disable automatic garbage collection."""
  8. def collect() -> int:
  9. """Run a full collection immediately.
  10. Returns an integer indicating the number of unreachable objects found.
  11. """
  12. def collect_hint() -> None:
  13. """Hint the garbage collector to run a collection.
  14. The typical usage scenario for this function is in frame-driven games,
  15. where `gc.disable()` is called at the start of the game,
  16. and `gc.collect_hint()` is called at the end of each frame.
  17. """
  18. def setup_debug_callback(cb: Callable[[str], None] | None) -> None:
  19. """Setup a callback that will be triggered at the end of each collection."""