This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author matthew.suozzo
Recipients matthew.suozzo
Date 2020-12-14.21:52:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607982741.59.0.377965211704.issue42551@roundup.psfhosted.org>
In-reply-to
Content
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 calls. However if the primitive call is registered immediately when the call context is entered, the recorded call would be instantaneous (i.e. 0s duration) which could throw off the percall statistics.

Even with the incomplete generator case, I think registering the primitive call on RETURN is the best of the two options. Although seeing 2/0 for the call count when RETURN wasn't reached might seem odd, it lines up with a conceptual model of a coroutine: An iterator represents a function returning a sequence; Exhausting that iterator corresponds to the function call completing; Incompletely exhausting corresponds to an abbreviated/incomplete function call.
History
Date User Action Args
2020-12-14 21:52:21matthew.suozzosetrecipients: + matthew.suozzo
2020-12-14 21:52:21matthew.suozzosetmessageid: <1607982741.59.0.377965211704.issue42551@roundup.psfhosted.org>
2020-12-14 21:52:21matthew.suozzolinkissue42551 messages
2020-12-14 21:52:21matthew.suozzocreate