Extend `FOR_ITER` specializations to cover other indexable sequences
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Currently, we specialize FOR_ITER for both tuple and list. We also handle tuple and lists specially in GET_ITER to support this specialization.
We should extend this specialization of iteration over sequences, using virtual iterators to bytes, str, bytesarray and others.
To do this, we should:
- Add a
tp_getiteritemslots toPyTypeObjectfor sequences that can be efficiently indexed and cannot raise except for out-of-bounds access. - Add a specialization of
FOR_ITERfor these classes. - Specialize
GET_ITERfor:- iterators
- indexable sequences (those classes with a
tp_getiteritemslot)
- Specialize
SENDfor indexable sequences which should also improve JIT coverage, as unspecialized_SENDis currently a major cause of jit optimization failures.
Combined with https://github.com/python/cpython/issues/145667 this will allow effective specialization of a wider range of iterables and allow that specialization not only for for loops, but also for yield from loops.
It will add 3 instructions (4 new, 1 removed) which a reasonable
Linked PRs
- gh-145670
- gh-147967
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc các specialization hiện có của FOR_ITER và GET_ITER, sau đó kiểm tra PyTypeObject và specialization của SEND. Công việc hoàn tất khi các sequence có thể lập chỉ mục như bytes và str sử dụng virtual iterator trong các vòng lặp for và vòng lặp yield from, với phạm vi bao phủ các instruction mới được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- compilers, performance
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100