Support __index__() in getrandbits(), randbytes() and others
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ả
Feature or enhancement
Support of the __index__() method in getrandbits() and randbytes() is inconsistent.
Random.getrandbits()supports__index__(), butSystemRandom.getrandbits()does not.SystemRandom.randbytes()supports__index__(), butRandom.randbytes()does not.
For consistence, both classes should support it.
sample() fails if its k argument is not integer. k should have __index__(), but it also should support comparison with integers and multiplication by list and integer. It is easy to make it more general, and only require __index__(). It will also produce more meaningful error.
binomialvariate() seems "working" with non-integer n argument, but the result is questionable. Passing non-integer value is most likely an error, and it would be better to detect it.
cc @rhettinger
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
Tìm các phần triển khai và các bài kiểm thử cho Random.getrandbits(), SystemRandom.getrandbits(), Random.randbytes(), SystemRandom.randbytes(), sample() và binomialvariate(). So sánh cách chúng xử lý các đối số không phải số nguyên, sau đó xác minh rằng các đối số được hỗ trợ luôn sử dụng index() một cách nhất quán và các đầu vào không hợp lệ của binomialvariate() bị từ chối.
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
- backend
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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
- 45/100