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

Offen
#98,574 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
20/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
c, python
Bereich
api

Rechercherichtung

Es werden keine Dateien, Tests oder spezifischen API-Einträge genannt. Beginne mit der Überprüfung der C DLL API auf die erwähnten Makros, Defines und globalen Variablen; lege eine begrenzte Menge von Funktionsalternativen fest und verifiziere, dass die ausgewählten Elemente exportiert werden und aus einem Wrapper auf höherer Ebene verwendbar sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
558

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/cpython

Alle Issues in python/cpython

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.