pkpy.pyi 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from typing import Self, Literal
  2. from vmath import vec2, vec2i
  3. class TValue[T]:
  4. def __new__(cls, value: T) -> Self: ...
  5. @property
  6. def value(self) -> T: ...
  7. # TValue_int = TValue[int]
  8. # TValue_float = TValue[float]
  9. # TValue_vec2i = TValue[vec2i]
  10. # TValue_vec2 = TValue[vec2]
  11. configmacros: dict[str, int]
  12. def memory_usage_info() -> str: ...
  13. def memory_usage() -> int: ...
  14. def currentvm() -> int:
  15. """Return the current VM index."""
  16. def watchdog_begin(timeout: int):
  17. """Begin the watchdog with `timeout` in milliseconds.
  18. `PK_ENABLE_WATCHDOG` must be defined to `1` to use this feature.
  19. You need to call `watchdog_end()` later.
  20. If `timeout` is reached, `TimeoutError` will be raised.
  21. """
  22. def watchdog_end() -> None:
  23. """End the watchdog after a call to `watchdog_begin()`."""
  24. def profiler_begin() -> None: ...
  25. def profiler_end() -> None: ...
  26. def profiler_reset() -> None: ...
  27. def profiler_report() -> dict[str, list[list]]: ...
  28. class ComputeThread:
  29. def __init__(self, vm_index: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]): ...
  30. @property
  31. def is_done(self) -> bool:
  32. """Check if the current job is done."""
  33. def wait_for_done(self) -> None:
  34. """Wait for the current job to finish."""
  35. def last_error(self) -> str | None: ...
  36. def last_retval(self): ...
  37. def submit_exec(self, source: str) -> None:
  38. """Submit a job to execute some source code."""
  39. def submit_eval(self, source: str) -> None:
  40. """Submit a job to evaluate some source code."""
  41. def submit_call(self, eval_src: str, *args, **kwargs) -> None:
  42. """Submit a job to call a function with arguments."""
  43. def exec(self, source: str) -> None:
  44. """Directly execute some source code."""
  45. def eval(self, source: str):
  46. """Directly evaluate some source code."""