Skip to content

Object protocol #3306

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

Merged
merged 1 commit into from
Oct 16, 2021
Merged

Object protocol #3306

merged 1 commit into from
Oct 16, 2021

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Oct 14, 2021

I also suggest to replace the paired vm methods and use PyObjectRef methods

ref #3244

Comment on lines 489 to 490
fn __hash__(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyHash> {
Self::slot_hash(&zelf, vm)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to include in this PR, not in #3308 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He'll probably just rebase those changes here now that they've been merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The below Unhashable changes require this. Will moving them into #3308 be better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to move it over to #3308

Copy link
Contributor

@Snowapril Snowapril Oct 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to move it over to #3308

Sorry for late 😢. I also agree with him

@DimitrisJim
Copy link
Member

I also suggest to replace the paired vm methods and use PyObjectRef methods

yup, I think that's a good idea. After this pr there will be two ways to do the same thing. As I see it, these operations act on objects so they should be exposed through there and not through vm.

@DimitrisJim
Copy link
Member

DimitrisJim commented Oct 16, 2021

should ItemProtocol impl be moved here too?

@youknowone
Copy link
Member Author

Probably. I doub't we really need that trait now. I think relocating impl ItemProtocol for PyObjectRef to here, impl ItemProtocol for PyDictRef to its impl and removing the trait could be better than now.

@DimitrisJim
Copy link
Member

The delitem/setitem/getitem in PyDict would need to also be made public so objects that are known to be dicts to be able to call directly into them.

@youknowone
Copy link
Member Author

@DimitrisJim could you review it? I want to open issue for relocating functino bodies and refactoring around them.

Copy link
Member

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had reviewed but this does lgtm.

@youknowone youknowone merged commit 273193f into RustPython:main Oct 16, 2021
@youknowone youknowone deleted the object-protocol branch October 16, 2021 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants