-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-107674: Lazy load line number to improve performance of tracing #118127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lazy load frame line number to improve performance of tracing |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,12 +41,20 @@ int | |
PyFrame_GetLineNumber(PyFrameObject *f) | ||
{ | ||
assert(f != NULL); | ||
if (f->f_lineno != 0) { | ||
return f->f_lineno; | ||
if (f->f_lineno == -1) { | ||
// We should calculate it once. If we can't get the line number, | ||
// set f->f_lineno to 0. | ||
f->f_lineno = PyUnstable_InterpreterFrame_GetLine(f->f_frame); | ||
if (f->f_lineno < 0) { | ||
f->f_lineno = 0; | ||
return -1; | ||
} | ||
} | ||
else { | ||
return PyUnstable_InterpreterFrame_GetLine(f->f_frame); | ||
|
||
if (f->f_lineno > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that makes sense. |
||
return f->f_lineno; | ||
} | ||
return PyUnstable_InterpreterFrame_GetLine(f->f_frame); | ||
} | ||
|
||
static PyObject * | ||
|
Uh oh!
There was an error while loading. Please reload this page.