GH-96793: Specialize FOR_ITER for generators. by markshannon · Pull Request #98772 · python/cpython · GitHub

github.com

Tin mới

faster-cpython:specialize-for-iter-gen

GitHub CopilotWrite better code with AI

GitHub Copilot appDirect agents from issue to merge

ActionsAutomate any workflow

CodespacesInstant dev environments

IssuesPlan and track work

Code ReviewManage code changes

Code QualityEnforce quality at merge

GitHub Advanced SecurityFind and fix vulnerabilities

Code securitySecure your code as you build

Secret protectionStop leaks before they start

View all use cases

Financial services

View all industries

Software Development

GitHub SponsorsFund open source developers

Copilot for BusinessEnterprise-grade AI features

Premium SupportEnterprise-grade 24/7 support

Pull requests 2.6k

Security and quality 0

Enable specialization of iteration over generators, for gen():, and awaiting coroutines, await coro() #96793

Specialize FOR_ITER for generators.

awaiting core review

awaiting core review

https://github.com/python/cpython/compare/main...faster-cpython:cpython:specialize-for-iter-gen-handle-exc-stack?expand=1

https://github.com/python/cpython/compare/main...faster-cpython:cpython:specialize-for-iter-gen-handle-exc-stack?expand=1 fixes the gi_exc_state issue, but is messy. I think this would benefit from merging #96319 first

View reviewed changes

Learn more about hiding disruptive comments

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/python/cpython/pull/98772/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59deR2087

Because it's the offset for YIELD_VALUE to return to relative to RETURN_VALUE https://github.com/python/cpython/pull/98772/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59deR2087

https://github.com/python/pyperformance/blob/main/pyperformance/data-files/benchmarks/bm_generators/run_benchmark.py

I suspect there aren't enough uses of generators in the benchmark suite for this to make a difference.

Merge branch 'main' into specialize-for-iter-gen

Clean up after merge.

View reviewed changes

Add test for nested exc_info in loop.

View reviewed changes

Use new API for current exception

pylint is broken with CPython main #101914

Python 3.12 - ValueError: generator already executing pylint-dev/pylint#9138