The Wayback Machine - https://web.archive.org/web/20220514080301/https://github.com/RustPython/RustPython/issues/3631
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
youknowone opened this issue Apr 17, 2022 · 1 comment · Fixed by #3630
Closed

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

youknowone opened this issue Apr 17, 2022 · 1 comment · Fixed by #3630
Labels

Comments

@youknowone
Copy link
Member

@youknowone youknowone commented Apr 17, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant