Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.12] cProfile counts 0 primitive calls for builtins.exec in certain scenario #106152

Closed
Assignees
gaogaotiantian
Labels
3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error
@jacobtylerwalls

Description

@jacobtylerwalls

Bug report

In 3.12, cProfile can count 0 primitive calls and miscalculate cumulative time in the following scenario.

For this layout:

script.pyproject/    typing.py

And the file contents:

script.py

importproject.typing

project/typing.py

fromtypingimportProtocolclassA(Protocol): ...

I observe this behavior difference withpython3 -m cProfile script.py:

3.11.2

         697 function calls (693 primitive calls) in 0.001 seconds   Ordered by: cumulative time   ncalls  tottime  percall  cumtime  percall filename:lineno(function)      2/1    0.000    0.000    0.001    0.001 {built-in method builtins.exec}        1    0.000    0.000    0.001    0.001 script.py:1(<module>)

3.12.0b3

         635 function calls (630 primitive calls) in 0.001 seconds   Ordered by: cumulative time   ncalls  tottime  percall  cumtime  percall filename:lineno(function)        1    0.000    0.000    0.001    0.001 script.py:1(<module>)...      1/0    0.000    0.000    0.000          {built-in method builtins.exec}

Notice the division by zero causing a missingpercall stat for exec.


This means that in more substantial examples, the profiler will omit a significant portion of the relevant cumulative time. See this output for a 14.286 second script, I only have access to a cumtime for 0.800:

         45856453 function calls (31647888 primitive calls) in 14.286 seconds   Ordered by: cumulative time   ncalls  tottime  percall  cumtime  percall filename:lineno(function)     4054    0.005    0.000    0.800    0.000 modutils.py:620(_spec_from_modpath)    ...

Your environment

  • CPython versions tested on: Python 3.12.0b3
  • Operating system and architecture: MacOS 13.4.1

Linked PRs

Metadata

Metadata

Labels

3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp