NVIDIA / NVIDIA/cuda-python

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

Aperta
#2,766 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

cuda.bindings performance triage
Lingua principale
Cython
Stelle
3.4k
Fork
329
Merge medio
1g 21h
PR unite (30g)
113

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia individuando le funzioni nel livello lowpp e verificando come vengono esposte a Cython e Python. Confronta il comportamento cpdef esistente con i vincoli indicati relativi a .pyi e alle prestazioni, quindi controlla la discussione per verificare se è stata presa una decisione. Il lavoro è completato quando il progetto ha concordato se mantenere o meno l’esposizione a Cython; l’issue non identifica file o test specifici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
backend
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Attiva
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.