python / python/cpython

`PyConfig.lazy_imports` is missing from the C API configuration docs

Đang mở
#155,273 0 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 topic-C-API topic-lazy-imports
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

lazy_imports is a PUBLIC entry in PYCONFIG_SPEC (Python/initconfig.c:127) and a member of PyConfig (Include/cpython/initconfig.h:194), so it can be read at runtime. It is the only one of the 25 PUBLIC options with no entry in Doc/c-api/init_config.rst, neither in the Configuration Options list nor as a c:member: of PyConfig.

import ctypes

api = ctypes.pythonapi
api.PyConfig_Get.restype = ctypes.py_object
api.PyConfig_Get.argtypes = [ctypes.c_char_p]

for name in (b"lazy_imports", b"inspect", b"int_max_str_digits"):
    print(name.decode(), "->", api.PyConfig_Get(name))
lazy_imports -> -1
inspect -> False
int_max_str_digits -> 4300

grep -c lazy_imports Doc/c-api/init_config.rst returns 0, while the other two names in that output are both documented there.

PEP 810 (GH-142351) documented the feature elsewhere: -X lazy_imports, PYTHON_LAZY_IMPORTS and the C functions in Doc/c-api/import.rst all landed with it. init_config.rst looks like the file it missed.

The value is a tri-state and that is undocumented too. Python/initconfig.c:1092 says lazy_imports can be -1 (default) or 1 (on), and that 0 is rejected later.

3.15 has the same gap: the spec entry is there and the doc entry is not.

Linked PRs
  • gh-155274
  • gh-155281

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 trong Doc/c-api/init_config.rst và so sánh các Configuration Options cùng các mục c:member của PyConfig trong đó với Python/initconfig.c:127 và Include/cpython/initconfig.h:194. Kiểm tra Python/initconfig.c:1092 để xác minh hành vi tri-state được ghi nhận, sau đó đảm bảo tài liệu hoàn chỉnh bao quát lazy_imports và các giá trị được chấp nhận của nó.

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
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.