Export real functions for things that currently exist as macros / defines / global variables in the C code

未關閉
#98,574 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
20/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
c, python
領域
api

研究方向

沒有指定檔案、測試或特定的 API 項目。先檢視 C DLL API,尋找提到的巨集、define 和全域變數;定義一組有限的函式替代方案,並驗證選取的項目已匯出且可從更高層級的 wrapper 使用。

由索引模型根據 Issue 內容生成。

描述

interpreter-core type-feature

Feature or enhancement

(A clear and concise description of your proposal.)

Pitch

I am writing a python wrapper in a higher level language using the C DLL API. Within certain higher level languages, it is not easily possible to access anything other than the exported functions from the DLL. Macros / defines / global variables are troublesome to interact with from the DLL.

So, If I only have easy access to the function API in my higher level language, type checking sort of becomes an issue due to things like PyList_Check being a macro and PyList_Type being a global variable. Exposing global variables (such as PyList_Type) through function APIs that just return a pointer to the data (for example) prevents a structure re layout from leaking out of the DLL... not to mention gives easier access to the data I need to call a type check function.

For things like PyList_Check that are macros, but are still useful for direct checks, they could be converted to a function API.

(Explain why this feature or enhancement should be implemented and how it would be used.
Add examples, if applicable.)

I do not suggest converting macros / defines cold turkey into a function API... obviously, that could break a lot of code for users of the C library. Instead, provide function alternatives to the items as a parallel API for those of us that can only really call DLL functions in our higher level language. As I go through some of the C API, I do notice areas where a macro and a function form of an API do exist in parallel. It would be nice if we could continue to extend that, especially for type checks.

Previous discussion

Apologies if this is discussed elsewhere. Move or edit as needed.

主要語言
Python
星號
77.2k
分支
36k
平均合併
1 天 9 小時
30 天內合併 PR
558

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python/cpython 的其他 Issue

查看 python/cpython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。