capi-workgroup / api-revolution

Proposals for radical or controversial API changes
29 stars 0 forks source link

Handles / Opaque linear references #7

Open encukou opened 1 year ago

encukou commented 1 year ago

Reference counting (incref/decref) is replaced by what HPy calls handles, and Mark's proposal Opaque, linear references:

HPy shows that this enables a moving GC. It does need all users to update all their code, so CPython probably can't ever require this. But we could provide PyRef_Dup/PyRef_Close/PyRef_Is (implemented as Py_INCREF/Py_DECREF/Py_Is) to allow users to signal that they're using handle semantics, and are (theoretically) compatible with implementations that use a moving GC.

gvanrossum commented 1 year ago

Why are these called "linear references"? Is there a common definition of that term?

encukou commented 1 year ago

@markshannon, there's some academic background for the term, right? I hope I'm using it correctly :)

jeanas commented 1 year ago

Why are these called "linear references"? Is there a common definition of that term?

See https://en.wikipedia.org/wiki/Substructural_type_system#Linear_type_systems

vstinner commented 4 months ago

See also https://github.com/capi-workgroup/problems/issues/37