`PyType_GetModuleByDef` is really slow.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
PyType_GetModuleByDef does a lot of work for what was a single memory read prior to sub-interpreters.
For example, https://github.com/python/cpython/issues/114682.
We should provide a more efficient way to get to the module state from the module def.
AFAICT, the function to get the module state is a pure function of the interpreter and the module def.
Since the module def already has a m_index field that is described as "The module's index into its interpreter's modules_by_index cache.", then a Py_GetModuleFromDef() function could be as simple as:
inline PyObject *
Py_GetModuleFromDef(PyModuleDef *def)
{
return PyInterpreterState_Get()->modules_table[def->m_base.m_index];
}
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 với PyType_GetModuleByDef, PyModuleDef.m_index và cache modules_by_index của trình thông dịch được nêu trong issue. So sánh đường dẫn tra cứu hiện tại với API module-from-definition được đề xuất và xác minh rằng hành vi vẫn chính xác theo từng trình thông dịch, đồng thời xử lý overhead đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, python
- Lĩnh vực
- backend-api-design, performance
- 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
- 35/100