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 摘要。