python / python/cpython

Minor change to LOAD_ATTR Opcode in 3.13 not documented

Đang mở
#138,402 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

docs interpreter-core
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

The order that items are pushed to the stack by LOAD_ATTR changed in 3.13, but this is not mentioned in the dis module documentation for the LOAD_ATTR Opcode.

Further Details

For the LOAD_ATTR Opcode, the following change from 3.12 is documented

Changed in version 3.12: If the low bit of namei is set, then a NULL or self is pushed to the stack before the attribute or unbound method respectively.

And this can be seen in frameobject.c: https://github.com/python/cpython/blob/3.12/Objects/frameobject.c#L422 where NULL is pushed before Object.

However, in 3.13 this has changed, presumably due to changes to the CALL Opcode;

Changed in version 3.13: The callable now always appears at the same position on the stack.

And for LOAD_ATTR the NULL is now pushed to the stack after the attribute or unbound method.

This ordering change can be seen in frameobject.c for 3.13: https://github.com/python/cpython/blob/3.13/Objects/frameobject.c#L1280 where Object is now pushed before NULL.

Suggested Resolution

My suggestion would be adding something like this to the LOAD_ATTR documentation;

Changed in version 3.13: When the low bit of namei is set, NULL or self is pushed to the stack after the attribute or unbound method respectively.

Linked PRs
  • gh-138631

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với mục LOAD_ATTR trong tài liệu về mô-đun dis của Python 3.13 và so sánh cách diễn đạt của mục này với các vị trí trong frameobject.c của 3.12 và 3.13 được liên kết trong issue. Kiểm tra PR gh-138631 được liên kết trước khi thực hiện thay đổi; tài liệu được hoàn tất khi thay đổi về thứ tự stack trong 3.13 được ghi lại chính xác.

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ó
1/5
Thời gian dự kiến
Dưới một 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
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.