Message396667
When dumping profiling data out of code objects using out-of-process tools like Austin (https://github.com/p403n1x87/austin) one has access only to file name, function name, and line number. Consider the flame graph generated by running the following script, and aggregating on function names
----
class Foo:
def on_cpu(self, n):
a = []
for i in range(n):
a.append(i)
class Bar:
def on_cpu(self, n):
a = []
for i in range(n):
a.append(i)
if __name__ == "__main__":
f = Foo()
b = Bar()
f.on_cpu(1_000_000)
b.on_cpu(5_000_000)
----
Without the extra information coming from the actual Python source, one would not be able to tell, by looking at the flame graph alone, that on_cpu has contributions from two different methods. By propagating the qualname information from the compiler to code objects, such names would be disambiguated and the resulting flame graph would be clearer.
I would like to propose adding the co_qualname field to the PyCodeObject structure, which is to be set to NULL except for when the code object is created by the compiler in compile.c. |
|
Date |
User |
Action |
Args |
2021-06-28 22:35:33 | Gabriele Tornetta | set | recipients:
+ Gabriele Tornetta |
2021-06-28 22:35:33 | Gabriele Tornetta | set | messageid: <1624919733.39.0.974767657181.issue44530@roundup.psfhosted.org> |
2021-06-28 22:35:33 | Gabriele Tornetta | link | issue44530 messages |
2021-06-28 22:35:33 | Gabriele Tornetta | create | |
|