Skip to content

Commit 00de79a

Browse files
committed
Add Python 3.15 profiling stubs
1 parent 24f7cf4 commit 00de79a

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

stdlib/@tests/stubtest_allowlists/py315.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ posixpath.splitroot
178178
pprint.PrettyPrinter.__init__
179179
pprint.pformat
180180
pprint.pprint
181-
profiling
182-
profiling.sampling
183181
profiling.sampling.binary_collector
184182
profiling.sampling.binary_reader
185183
profiling.sampling.cli
@@ -196,7 +194,6 @@ profiling.sampling.pstats_collector
196194
profiling.sampling.sample
197195
profiling.sampling.stack_collector
198196
profiling.sampling.string_table
199-
profiling.tracing
200197
pydoc.Doc.STDLIB_DIR
201198
pydoc.Doc.getdocloc
202199
site.addsitedir

stdlib/VERSIONS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ posix: 3.0-
242242
posixpath: 3.0-
243243
pprint: 3.0-
244244
profile: 3.0-
245+
profiling: 3.15-
246+
profiling.sampling: 3.15-
247+
profiling.tracing: 3.15-
245248
pstats: 3.0-
246249
pty: 3.0-
247250
pwd: 3.0-

stdlib/profiling/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import sampling as sampling, tracing as tracing
2+
3+
__all__ = ["sampling", "tracing"]

stdlib/profiling/sampling.pyi

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from _typeshed import StrOrBytesPath
2+
from abc import ABC
3+
4+
__all__ = [
5+
"Collector",
6+
"PstatsCollector",
7+
"CollapsedStackCollector",
8+
"HeatmapCollector",
9+
"GeckoCollector",
10+
"JsonlCollector",
11+
"StringTable",
12+
]
13+
14+
class Collector(ABC):
15+
def collect(self, stack_frames, timestamps_us=None) -> None: ...
16+
def collect_failed_sample(self) -> None: ...
17+
def export(self, filename: StrOrBytesPath) -> None: ...
18+
19+
class PstatsCollector(Collector):
20+
def __init__(self, sample_interval_usec: int, *, skip_idle: bool = False) -> None: ...
21+
def create_stats(self) -> None: ...
22+
def print_stats(self, sort=-1, limit: int | None = None, show_summary: bool = True, mode=None) -> None: ...
23+
24+
class CollapsedStackCollector(Collector):
25+
def __init__(self, *args, **kwargs) -> None: ...
26+
def process_frames(self, frames, thread_id: int, weight: int = 1) -> None: ...
27+
28+
class HeatmapCollector(Collector):
29+
FILE_INDEX_FORMAT: str
30+
def __init__(self, *args, **kwargs) -> None: ...
31+
def process_frames(self, frames, thread_id: int, weight: int = 1) -> None: ...
32+
def set_stats(
33+
self,
34+
sample_interval_usec: int,
35+
duration_sec: float,
36+
sample_rate: float,
37+
error_rate: float | None = None,
38+
missed_samples: int | None = None,
39+
**kwargs,
40+
) -> None: ...
41+
42+
class GeckoCollector(Collector):
43+
def __init__(self, sample_interval_usec: int, *, skip_idle: bool = False, opcodes: bool = False) -> None: ...
44+
45+
class JsonlCollector(Collector):
46+
def __init__(self, sample_interval_usec: int, *, skip_idle: bool = False, mode=None) -> None: ...
47+
def process_frames(self, frames, _thread_id: int, weight: int = 1) -> None: ...
48+
49+
class StringTable:
50+
def intern(self, string: object) -> int: ...
51+
def get_string(self, index: int) -> str: ...
52+
def get_strings(self) -> list[str]: ...
53+
def __len__(self) -> int: ...

stdlib/profiling/tracing.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from cProfile import Profile as Profile, run as run, runctx as runctx
2+
from types import CodeType
3+
from typing import TypeAlias
4+
5+
__all__ = ["run", "runctx", "Profile"]
6+
7+
_Label: TypeAlias = tuple[str, int, str]
8+
9+
def label(code: str | CodeType) -> _Label: ... # undocumented

0 commit comments

Comments
 (0)