PEP 554: Issues with data passing and pickle
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- reStructuredText
- Star
- 5k
- Fork
- 1.8k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 25
Mô tả
I believe the example program given in PEP 554: https://peps.python.org/pep-0554/#passing-objects-via-pickle has some issues. It's based on a zero value (b'\x00') being a data terminator, but my attempts to recreate this (using threads instead of interpreters) showed that pickle will insert zero values in the middle of the data stream:
Python 3.10.4 (main, May 7 2022, 16:23:10) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> pickle.dumps("PEP 554")
b'\x80\x04\x95\x0b\x00\x00\x00\x00\x00\x00\x00\x8c\x07PEP 554\x94.'
I think the goal here is to simply demonstrate passing pickled objects through the pipe. To that end, it might make a better example to change the reading portion to read a fixed, relatively large, buffer at once and then decode that. Something like:
data = os.read(reader, 1024)
obj = pickle.loads(data)
do_something(obj)
This is clearly not a general purpose solution, but I think for an example like this, not solving all of the corner cases is OK.
Thanks for all of the tremendous work already put into this! This will be very cool!
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
Mở phần “Passing Objects via Pickle” của PEP 554 và kiểm tra logic đọc từ pipe cũng như logic kết thúc của ví dụ. Đối chiếu ví dụ với đầu ra pickle được hiển thị, sau đó cập nhật ví dụ để hành vi được ghi lại trong tài liệu khớp với phần minh họa dự kiến và xác nhận rằng đoạn mã đã sửa có thể tải đối tượng pickle.
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100