Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Discussion: Should functions in lowpp layer be `def` rather than `cpdef`?

未关闭
#2,766 1 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@mdboom 已经在做这个了。

开始于 2026年9月24日。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
活跃
领域
backend

调研方向

首先定位 lowpp 层中的函数,并审查它们如何向 Cython 和 Python 公开。将现有的 cpdef 行为与所述的 .pyi 和性能约束进行比较,然后查看讨论以确认是否已有决定。项目就是否应保留 Cython 公开达成一致后,即视为完成;该 issue 未指出具体的文件或测试。

由索引模型根据 Issue 内容生成。

描述

P1

Functions in the lowpp layer are currently declared with cpdef, so they are exposed to both Cython and Python. However, we have always claimed that the Cython interface is not stable, and shouldn't be relied on.

A couple discoveries today are making me wonder whether we want to keep exposing the lowpp layer to Cython at all:

  • Calling a cpdef function from Python has an additional 50ns of overhead vs. a def function (the Python layer delegates to an underlying layer and there is additional work done at that boundary).
  • cpdef functions can not have their return type annotated, which is a blocker for proper .pyi support for the lowpp layer.

Is Cython access at the lowpp layer providing any value here? Could we just s/cpdef/def/g and get more performance and a more Pythonic experience?

主要语言
Cython
星标
3.4k
派生
334
平均合并
1 天 18 小时
30 天内合并 PR
143

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/cuda-python 的其他 Issue

查看 NVIDIA/cuda-python 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。