Skip to content

Private APIs used in Pyodide #79

@hoodmane

Description

@hoodmane

Here is the list of the private C APIs used by Pyodide. I tried to drop ones that have public equivalents on the main branch, but I may have accidentally kept some.

cc @vstinner

Argument parsing

  • _PyArg_CheckPositional -- argument clinic uses it, probably should be public?

Argument parsing for vectorcall, would be nice to have argument clinic variant
for these I guess?

  • _PyArg_Parser
  • _PyArg_ParseStack
  • _PyArg_ParseStackAndKeywords

Errors and tracebacks

  • _Py_DumpTraceback -- used for fatal errors
  • _PyTraceback_Add -- add JS frames to a Python traceback
  • _PyErr_FormatFromCause -- Chain exceptions conveniently

Generators

  • _PyGen_FetchStopIterationValue -- used to consume generators
  • _PyGen_SetStopIterationValue -- used to implement generators

Hashes

  • _Py_HashBytes -- use Python utility function for hashing my stuff rather than reimplement
  • _PyDict_GetItem_KnownHash -- several lookups in a row on same key

Numbers

  • _PyLong_AsByteArray -- For converting a Python int to a JS bigint
  • _PyLong_FromByteArray -- For converting a JS bigint to a Python int
  • _PyLong_NumBits -- Work out how much space to allocate for the bytearray passed to PyLong_FromByteArray
  • _PyNumber_Index -- much more common in internal Python code than
    PyNumber_Index. PyNumber_Index forces the return type to be exactly PyLong
    rather than a subtype. We can handle subtypes so we use the underscore version.

Other data structures

  • _PySet_Update
  • _PyUnicode_EQ

Miscellaneous

  • _PyObject_GetMethod -- caching for lookups on Python objects from JavaScript
  • _PyObject_NextNotImplemented -- checking if a Python object supports
    iteration, could be replaced with PyIter_Check

PyID functions

I could easily shim these; Pyodide is single threaded so they are nice.

  • _Py_IDENTIFIER
  • _PyObject_CallMethodIdNoArgs
  • _PyObject_CallMethodIdObjArgs
  • _PyObject_CallMethodIdOneArg
  • _PyObject_GetAttrId
  • _PyObject_SetAttrId
  • _PyUnicode_FromId

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions