Skip to content

[RFC] Give proper names to types and traits #3631

Closed

Description

@youknowone

Summary

By adding and removing types ad-hoc, we now have many types and traits related to describing Python objects. Giving proper names for them will reduce confusions.

Detailed Explanation

Types related to managed references

As-is

Management Typed Untyped
Interpreter-independent PyObjectView<T> PyObject
Reference-counted PyRef<T> PyObjectRef
Weak PyWeakRef<T> PyObjectWeak

Giving names to show their relationship will be great. It will be mostly cleared by renaming PyObjectView as Py, by following @coolreader18 's original suggestion when they worked about it.

I additionally suggest to remove PyObjectWeak and just go ahead by its internal type PyRef<PyWeak>, because PyObjectWeak doesn't look like PyRef at all. We mostly handle PyRef in the code, so it will be confusing.

To-be v1

Management Typed Untyped
Interpreter-independent Py<T> PyObject
Reference-counted PyRef<T> PyObjectRef
Weak PyWeakRef<T> PyRef<PyWeak>

Unfortunately, ur common naming convention implies PyWeakRef is PyRef<PyWeak>. So the left and right side of weak type is not distinguishable by the name. PyRefWeak or WeakPyRef will not be confusing.

To-be v2

Management Typed Untyped
Interpreter-independent Py<T> PyObject
Reference-counted PyRef<T> PyObjectRef
Weak PyRefWeak<T> PyRef<PyWeak>

PyValue -> PyPayload

By looking back the history, there was PyObjectPayload and PyObjectPayload2 but the latter one is renamed to PyValue. For now, it looks like describing a payload as its past name. We use functions like fn payload(), then fn payload_is() which indirectly based on PyValue through (still alive) PyObjectPayload.

We actually don't have concrete concept of "value".

Drawbacks, Rationale, and Alternatives

Unresolved Questions

Is PyObjectWeak intentionally wrapped as different object to prevent to call PyRef methods?

Activity

  1. youknowone commented on Apr 17, 2022

    @youknowone
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for comments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions