Lacking description of how to correctly implement indexing syntax support.
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ả
Documentation
During a discussion on idea of minimizing requirements for children of collections.abc.Sequence, it was pointed out, that documentation is currently lacking sufficient description on expected behaviour of method __getitem__.
The part in question starts with first note after __length_hint__ description. I started by writing, to see what's missing. Non-trivial changes include:.
- Translation of
a[1:2, 3:5]intoa[(slice(1, 2, None), slice(3, 5, None))]. - Because that translation exist, custom behaviour types (like matrix) are also supported.
- Slicing should return object of the same type, or at least similar.
- If description is good, then note about for loops is unnecessary. (Plus it's outdated, for loops call
iterandnext, the iterator calls__getitem__). - One object can implement both protocols correctly (at the same time).
- Setting
__iter__toNonemakesiternot fallback to sequence protocol. (And similar point forreversed). - Having ABC as parent, or explicitly assigning methods from them, isn't worst than not defining them at all.
- (After coping fallback description from
__reversed__, correct that)iterdon't need full sequence protocol, just__getitem__method.
Linked PRs
- gh-120942
- gh-122178
- gh-141124
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 tại phần tài liệu về mô hình dữ liệu Python ngay sau phần mô tả length_hint, theo tham chiếu được liên kết trong issue. So sánh các thay đổi được đề xuất với các PR đã liên kết gh-120942, gh-122178 và gh-141124; công việc được xem là hoàn tất khi các hành vi được liệt kê của getitem, slicing, phép lặp và giao thức reversed được ghi lại chính xác, đồng thời ghi chú lỗi thời về vòng lặp đã được xử lý.
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
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100