Skip to content

Commit 7645323

Browse files
tungolAlexWaygoodhauntsaninjaJelleZijlstra
authored
add _lsprof module (#11159)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent f3c7c48 commit 7645323

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extra-standard-library = [
7373
"_imp",
7474
"_json",
7575
"_locale",
76+
"_lsprof",
7677
"_markupbase",
7778
"_msi",
7879
"_operator",

stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ _heapq: 3.0-
3636
_imp: 3.0-
3737
_json: 3.0-
3838
_locale: 3.0-
39+
_lsprof: 3.0-
3940
_markupbase: 3.0-
4041
_msi: 3.0-
4142
_operator: 3.4-

stdlib/_lsprof.pyi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
from _typeshed import structseq
3+
from collections.abc import Callable
4+
from types import CodeType
5+
from typing import Any, Final, final
6+
7+
class Profiler:
8+
def __init__(
9+
self, timer: Callable[[], float] | None = None, timeunit: float = 0.0, subcalls: bool = True, builtins: bool = True
10+
) -> None: ...
11+
def getstats(self) -> list[profiler_entry]: ...
12+
def enable(self, subcalls: bool = True, builtins: bool = True) -> None: ...
13+
def disable(self) -> None: ...
14+
def clear(self) -> None: ...
15+
16+
@final
17+
class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]):
18+
if sys.version_info >= (3, 10):
19+
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls")
20+
code: CodeType | str
21+
callcount: int
22+
reccallcount: int
23+
totaltime: float
24+
inlinetime: float
25+
calls: list[profiler_subentry]
26+
27+
@final
28+
class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]):
29+
if sys.version_info >= (3, 10):
30+
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime")
31+
code: CodeType | str
32+
callcount: int
33+
reccallcount: int
34+
totaltime: float
35+
inlinetime: float

stdlib/cProfile.pyi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _lsprof
12
from _typeshed import StrOrBytesPath, Unused
23
from collections.abc import Callable
34
from types import CodeType
@@ -15,13 +16,8 @@ _T = TypeVar("_T")
1516
_P = ParamSpec("_P")
1617
_Label: TypeAlias = tuple[str, int, str]
1718

18-
class Profile:
19+
class Profile(_lsprof.Profiler):
1920
stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented
20-
def __init__(
21-
self, timer: Callable[[], float] = ..., timeunit: float = ..., subcalls: bool = ..., builtins: bool = ...
22-
) -> None: ...
23-
def enable(self) -> None: ...
24-
def disable(self) -> None: ...
2521
def print_stats(self, sort: str | int = -1) -> None: ...
2622
def dump_stats(self, file: StrOrBytesPath) -> None: ...
2723
def create_stats(self) -> None: ...

0 commit comments

Comments
 (0)