[issue42551] Generator `yield`s counted as primitive calls by cProfile

2020-12-14 Thread Matthew Suozzo
Matthew Suozzo added the comment: One of the problems with my proposed solution that I glossed over was how and where to count the primitive call. If the primitive call is only registered on RETURN (i.e. after all yields), a generator that is incompletely exhausted would have 0 primitive cal

[issue42551] Generator `yield`s counted as primitive calls by cProfile

2020-12-02 Thread Matthew Suozzo
New submission from Matthew Suozzo : # Issue When profiling a generator function, the initial call and all subsequent yields are aggregated into the same "ncalls" metric by cProfile. ## Example >>> cProfile.run(""" ... def foo(): ... yield 1 ... yield 2 ... assert tuple(foo()) == (1, 2)